Click here to Skip to main content
16,020,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi 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

1 solution

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

So, you need to use a ' twice, for example:
Delphi
//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: http://stackoverflow.com/questions/10025032/what-is-the-meaning-of-the-prefix-n-in-t-sql-statements[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900