Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL Delphi
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 25-Sep-12 1:06am

1 solution

Rate this: bad
good
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: http://stackoverflow.com/questions/10025032/what-is-the-meaning-of-the-prefix-n-in-t-sql-statements[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
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