I am currently upgrading our entire Delphi 2007 database to Delphi XE2. The biggest consideration is the conversion of ANSI to Unicode, which we examined by overriding all the base types (char / string) for ANSI types (ansichar / ansistring). This worked in many of our programs until I started working with the database.
The problem started when I converted a program that stores information read from a file into a SQL Server 2008 database. Suddenly, simple queries that used a string to search for data would fail, for example:
SELECT id FROM table WHERE name = 'something'
The field nameis varchar. I found that I was able to complete the request successfully, using a prefix string name N. I got the impression that it varcharcan only store ANSI characters, but it looks like it stores Unicode?
Additional info: name field in Delphi string[13], but I tried to reset [13]. Database mapping SQL_Latin1_General_CP1_CI_AS. We use ADO to interact with the database. Connection information is stored in the ODBC administrator.
NOTE. I solved my urgent problem thanks to a little direction from Panagiotis. The name we read from our map file is array[1..24] of AnsiChar. This value was implicitly converted to string[13], which included null characters. Thus, the name with 5 characters was really stored as 5 characters + 8 null characters in the database.
source
share