#1 2018-04-17 14:00:35

Quorren
Member
Registered: 2016-10-03
Posts: 14

MSSQL Cyrillic help!

I have declared table like

TMeterGroup = class (TSQLRecord)
  private
  fgroupID:RawUTF8;
  fName:RawUTF8;
  published
  property groupID:RawUTF8 index 40 read fgroupID write fgroupID  stored AS_UNIQUE;
  property Name:RawUTF8 index 50 read fName write fName  stored AS_UNIQUE;
end;

Saved one item into MSSQL
Then i am trying to read:

    MeterGroup := TMeterGroup.CreateAndFillPrepare(ExtDatabase,'');
    if MeterGroup.FillOne then

In that manner i can read proper cyrillic value in "Name"

Second test

J := ExtDatabase.RetrieveListJSON( TMeterGroup,'',[],'');

and my cyrilic value become something else.

What did i miss?. Help me please.

Offline

#2 2018-04-17 14:23:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: MSSQL Cyrillic help!

Which SynDB class/unit are you using?

But CreateAndFillPrepare calls internally RetrieveListJSON, so I guess you may be making some confusion about charsets and encoding of strings.
RawUTF8 contains Unicode, but UTF-8 encoded, so you need to use UTF8ToString() to retrieve some VCL-compatible content.

Offline

#3 2018-04-17 16:44:19

Quorren
Member
Registered: 2016-10-03
Posts: 14

Re: MSSQL Cyrillic help!

Thank you for advice.

J := ExtDatabase.RetrieveListJSON( TMeterGroup,'',[],'');
s:=UTF8ToString(J);

works as i wanted to.

I am using

MSDBProps:=TOleDBMSSQL2012ConnectionProperties.Create(
...
VirtualTableExternalRegister(aModel,TMeterGroup,MSDBProps,'');
ExtDatabase:=TSQLRestServerDB.Create(aModel,':memory:');

Last edited by Quorren (2018-04-17 16:46:43)

Offline

Board footer

Powered by FluxBB