Page 1 of 1

Character Encoding Problem

Posted: 07.11.2013, 11:22
by ljubomir.djokic
Hi,
I have problem with displaying russian characters from ms sql database. I managed to properly display it using TADOConnection but not with TZConnection (which I prefer).

Delphi XE5
Zeos 7.1.2
MS SQL Server 2008

Here is my table

Code: Select all

CREATE TABLE [dbo].[DUMMY](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [varchar](100) NULL,
	[ENGLISH] [varchar](100) NULL,
	[RUSSIAN] [nvarchar](255) NULL,
 CONSTRAINT [PK_DUMMY] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
Try inserting русский directly into table using MSSQL Management Studio because

Code: Select all

INSERT INTO DUMMY VALUES ('NAME', 'ENGLISH', 'русский')
is not working.

In Delphi XE5 I placed TZConnction, TZTable, TDataSet and TDBGrid.
I use mssql protocol for TZConnection (which requires ntwdblib.dll)
and link it altogether and set up all properties.

Insted of русский I got ????????.

If I use TADOConnection and TADOTable everything is fine.

I'm out of idea. Please help.

Thanks

Re: Character Encoding Problem

Posted: 09.11.2013, 18:00
by EgonHugeist
Hi,

ADO is WideString based the the ODBC-specific Driver is doing the conversions.

mssql via ntwlib/dblib.dll and FreeTDS are Ansi-Based. Zeos does convert the values down to AnsiStrings and if your locale codepage doesn't support these characters, than the result is '?..?'

But i've implemented a solution:

TZQuery.SQL.Text := INSERT INTO DUMMY VALUES ('NAME', 'ENGLISH', N:UnicodeParam);
TZQuery.ParamByName('UnicodeParam').AsString/AsWideString := 'русский';
TZQuery.ExecSQL;

So use Parameters and keep track they are signed as !N! for NChar-Columns. Than Zeos converts it to UTF8-Raw.