Click here to Skip to main content
12,955,614 members (60,760 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a column of nvarchar or nchar in SQL Server DB which have fields in Persian language.
For search , I should use of character "N" before parameter.
But I don’t know how do it.
The following commands don’t be work properly:
ADOQuery.SQL.text :=('SELECT * ');
ADOQuery.SQL.add('FROM my_table ');
ADOQuery.SQL.add('WHERE my_name = N' + ': my_name _p' );
ADOQuery.Parameters.ParamByName(' my_name _p ').Value := trim(my_name.Text) ;

Thanks very much
Posted 25-Sep-12 0:06am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The WHERE condition should looks like:
WHERE [Name] = N'Samuel'

So, you need to use a ' twice, for example:
//declare variable to store SQL command
sSQL: string;
//set the value
sSQL := 'SELECT * FROM my_table WHERE my_name = N'':my_name_p''';
ADOQuery.SQL.text := sSQL;
ADOQuery.Parameters.ParamByName('my_name_p').Value := trim(my_name.Text);

More about N in sql queries:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,719
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,060
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100