[unixODBC-dev] SQLDriverConnectW() returns an error !

Nick Gorham nick.gorham at easysoft.com
Thu Jun 23 09:46:10 BST 2005


Anita Dixit wrote:

>I tried using 2.2.11. However the problem doesn't seem to resolve.
>Following is the code that I am trying out - 
>
>  
>

I am not sure what wstrcpy you are using, but

L"DSN=MyDriver;Database=QA"

will create a array of 4 byte characters. unixODBC by default, will use the 2 byte UNICODE as odbc does on windows, so you could try something like

void wstrconvert( SQLWCHAR *out, char *in ) {
        while( *in ) {
                *out++ = *in++;
        }
        *out = 0;
}

...

memset( connectionInfoBuffer, 0, 1024);
wstrconvert(connStr,"DSN=MyDriver;Database=QA");


And a further problem, you call

SQLGetDiagRecW( SQL_HANDLE_DBC, hdbc, i, sqlstate,
&sqlcode, message, 10000, &length)

but then call

printf( "SQLSTATE          = <%s>\n", sqlstate ) ;

Again, sqlstate and message will be a two byte UNICODE string.

-- 
Nick Gorham
Easysoft Limited



More information about the unixODBC-dev mailing list