Lazarus

Programming => Databases => Topic started by: luca on March 31, 2021, 10:10:19 pm

Title: ODBC MSSQL NChar issue
Post by: luca on March 31, 2021, 10:10:19 pm
I'm importing some data from the ERP to my local app.
ERP and my app are using MSSQL as DBMS.
One field (Name) is defined as nchar(20) in both tables.

I read one record using a query and insert it in destination table using a parametizer query: 
Code: Pascal  [Select][+][-]
  1. qryDEST.ParamByName('NAME').AsWideString:=qryORI.FieldByName('NAME').AsWideString;
If the Name is a string composed only of one byte char all is fine.
If the Name contains 20 chars and one of them is a unicode char (example ยต) I received the error from MSSQL: string binary will be truncated.

In Debug I see the right text.

Is it an error in my program or is it a limitation in ODBCConn?

Regards
Luca

Title: Re: ODBC MSSQL NChar issue
Post by: Gustavo 'Gus' Carreno on March 31, 2021, 10:37:26 pm
Hey Luca,

Can't really answer your question 100% and for that I'm sorry.

But in the mean time, let's cover our bases:

If so, then I bow out and let the real experts take charge of this one.

I'm still learning, myself, which type of string to use when dealing with Unicode stuff...

Cheers,
Gus
Title: Re: ODBC MSSQL NChar issue
Post by: luca on April 01, 2021, 08:30:01 am
Hi,
both db are using same charset and they are Unicode compatible.

Regards
Luca
Title: Re: ODBC MSSQL NChar issue
Post by: luca on April 01, 2021, 12:00:25 pm
I've fixed the problem.
There is another field I didn't convert using AsWideString.

Now it's working.

Regards
Luca
TinyPortal © 2005-2018