SMMB
SMMB

Reputation: 127

How do I read unicode characters from SQL server using SQLAPI++?

I'm using SQLAPI++ to build a backend application which needs to access a database (SQL Server 2014). When I try to read a string (nvarchar(50)) from a result set that contains non-ascii characters (specifically persian characters), the cmd.Field("MyField").asString().GetxxxChars() methods all return question marks (?) instead of those characters. What should I do?

I have also tried asBytes() and asLongChar() and got the same results.

Upvotes: 1

Views: 217

Answers (1)

SMMB
SMMB

Reputation: 127

So I found the problem!

I was linking with sqlapis.lib. I checked this link and found out that I should use sqlapius.lib instead for unicode support. I also needed to define SA_UNICODE.

It is now working fine.

Upvotes: 1

Related Questions