garbled characters appear in the query

Forum related to MS SQL Server

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
zhuyl
Junior Boarder
Junior Boarder
Posts: 26
Joined: 22.11.2021, 09:09

garbled characters appear in the query

Post by zhuyl »

Connecting to the SQL server in lazarus, when the field is of type varchar and the value is Chinese, garbled characters appear in the query.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: garbled characters appear in the query

Post by marsupilami »

Hello :)

Which version of Zeos do you use and which version of FPC? Are you on Windows or Linux? Do you use FreeTDS or ODBC? Did you set the ClientCodepage to UTF-8?

Best regards,

Jan
zhuyl
Junior Boarder
Junior Boarder
Posts: 26
Joined: 22.11.2021, 09:09

Re: garbled characters appear in the query

Post by zhuyl »

Zeos version 7.2.14, FPC version 3.2.0, on windows, use FreeTDS, set ClientCodepage to UTF-8
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: garbled characters appear in the query

Post by marsupilami »

Ok - I did a test run. Our test suites currently don't show problems related to international characters and FreeTDS. Could you please try to create a sample application that shows the problem? The application should have:
- an SQL script for creating the database
- the source of a small Lazarus application that shows the problem

This would help me a lot in debugging the problem.

Best regards,

Jan
zhuyl
Junior Boarder
Junior Boarder
Posts: 26
Joined: 22.11.2021, 09:09

Re: garbled characters appear in the query

Post by zhuyl »

I create a test project
You do not have the required permissions to view the files attached to this post.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: garbled characters appear in the query

Post by marsupilami »

Hello zhuyl,

on Zeos 7.2.14 please use "FreeTDS_MsSQL>=2005" for ZConnection1.Protocol. FreeTDS behaves differently to Microsofts ntwdblib.dll when it comes to varchar fields. This is why you have to use a different protocol.
Also please update your FreeTDS. Your version is rather old. New versions can be retrieved from the FreeTDS integration tests on appveyor or from our files section. Please note that the builds on our files section don't ret updated regularly.

Unfortunately I don't have Lazarus with Zeos 7.2 around. I can only test on Zeso 8.0. Your example works perfectly on Zeos 8.0. Please note that on Zeos 8.0 you have to use the mssql protocol (again). On Zeos 8.0 we don't support the outdated ntwdblib.dll anymore and use mssql as a synonym for freetds.

Best regards,

Jan
zhuyl
Junior Boarder
Junior Boarder
Posts: 26
Joined: 22.11.2021, 09:09

Re: garbled characters appear in the query

Post by zhuyl »

Hello, thank you for your patient answers. The problem has been solved, which is the reason why the FreeTDS version you mentioned is too old. The new version is ok.
zhuyl
Junior Boarder
Junior Boarder
Posts: 26
Joined: 22.11.2021, 09:09

Re: garbled characters appear in the query

Post by zhuyl »

hello,How to use prepared property? My test cannot execute the prepared SQL statement 。
Post Reply