Wednesday, March 7, 2012

How to compare chinese words/signs in a sql-statement?

I have the following line of (delphi)code:

SQL.Add('SELECT Language_ID FROM Languages WHERE Language_Name = :language');
ADOQuery2.Parameters.ParamByName('language').Value := TntComboBox1.Text;

TntComboBox1.Text is an widestring with chinese marks, which it got from the same database.

After more then an hour, i used the query analyzer and i saw, MS SQL cant compare chinese signs. (its not delphi's fault, i tested)

Must i change some settings? And where?
I can insert the chinese language and put in a table for example, without a problem...

thnx,
ErikAre your field types set to unicode NCHAR and NVARCHAR?

blindman|||Yes, i have, otherwise i can't insert and select it.
I can't do:
SELECT something FROM table WHERE column_with_chinese_signs = 'chinese_Sign R'
R

only with:
SELECT something FROM table WHERE column_with_chinese_signs = N'chinese_Sign R'

see the N!

but now i can't implement it in Delphi... SQL.ADD('... = N x')
x is a variable (e.g. a sign but can also be a word)

I hpe i was clear

No comments:

Post a Comment