Auto prefix 'N' for unicode string literals?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
GMG
Posts: 6
Joined: Wed 28 Apr 2010 16:21

Auto prefix 'N' for unicode string literals?

Post by GMG » Fri 21 May 2010 16:19

We have a lot of code we have to make compatible with SQL Server Unicode, and prefixing all string literals with 'N' is one of the required changes.

Is this by any chance something the can be done behind the scenes by the DevArt drivers, say, using a connection parameter?

I don't see any in the documentation, but I thought it would be worth a check.

Thanks very much!

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 25 May 2010 12:31

DbxSda supports Unicode. To use Unicode you should set the proper parameter of TCRSQLConnection to True, like this:
TCRSQLConnection.Params.Add('UseUnicode=True');

GMG
Posts: 6
Joined: Wed 28 Apr 2010 16:21

Post by GMG » Fri 28 May 2010 04:42

Thanks. I had this in the initialization, and unicode parameters work fine, but SQL without parameters like this do not:

update table set col='CHINESE TEXT'

-- select shows '?????????'

update table set col = N'CHINESE TEXT'

-- select shows 'CHINESE TEXT'

So, we have to update our SQL to add the N.

Correct?

Thanks again for the help.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 28 May 2010 11:09

Yes, it is right.

Post Reply