What error message do you get back from the SQLConnectW?
using 4 byte unicode is always going to cause problems. The DM will convert to single bytes if the driver doesn't expose the W functions. But if it does, it will pass the 4 byte unicode on as it is, so you need to ensure that the driver also understands 4 byte unicode.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I use SQLConnect, it is OK. And I can get data from the database.
But when I use the code below
#define SQL_WCHART_CONVERT
#define UNICODE
#include <sqlext.h>
#include <sqlucode.h>
SQLConnectW(hdbc,
(SQLTCHAR*)(L"mytest"), SQL_NTS,
(SQLTCHAR*)(L"sa"), SQL_NTS,
(SQLTCHAR*)(L"aaa999"), SQL_NTS);
The return code is -1.Why?
My environment:
fedora core 14
gcc 4.5.1
unixODBC 2.3.0
sql server 2000 sp4
freetds
thanks!
Hi,
What error message do you get back from the SQLConnectW?
using 4 byte unicode is always going to cause problems. The DM will convert to single bytes if the driver doesn't expose the W functions. But if it does, it will pass the 4 byte unicode on as it is, so you need to ensure that the driver also understands 4 byte unicode.
The error message is unreadable code
So I have to use
SQLTCHAR buf = {0};
SQLGetDiagRec( SQL_HANDLE_DBC, hdbc, 1,
odstat, &oderr, buf, SQL_MAX_MESSAGE_LENGTH, &len );
char* p = (char*)buf;
for (int i = 0; i < len; ++i)
{
cout << p;
p += 2;
}
cout << endl;
Then I get the next message:
Data source name not found, and no default driver specified
Is this mean the driver can not support?