Thursday, February 16, 2012

About ODBC + VC++

Hi,

I can't get ntext field value from my database (or nvarchar).

If I write in my database in english, I get only the 2 first letters.

If I write in my database in hebrew, I get gibbrish letters.

please I need some help

I'm using sql serser 2000, CRecordset, CDatabase, ODBC

Code Snippet

CDBVariant val;

rs.GetFieldValue("activity",val);

CString activity = (*activityVal.m_pstring).GetBuffer(0);

I'm sorry but I've not used MFC very much, but I've used ODBC, and this looks to me like you're fetching Unicode characters into ANSI buffers. The first thing I would try is defining your application as a Unicode app by adding the following add the beginning of your code:

#define UNICODE

#define _UNICODE

Here's a link to using ODBC via MFC: http://msdn2.microsoft.com/en-us/library/s9ds2ktb(VS.80).aspx

Hopefully someone else on this alias is more familiar with MFC to help you out.

Good luck!

~Warren

|||

Thank's,

Do you know how can I define these in my project? how to use this?

#define UNICODE

#define _UNICODE

No comments:

Post a Comment