Character Encoding Problem

Forum related to MS SQL Server

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
ljubomir.djokic
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 07.11.2013, 10:26

Character Encoding Problem

Post 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
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Character Encoding Problem

Post 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.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply