Re: mySQL and SQLDriverConnect

Igor Korot <[email protected]>
Newsgroups gmane.comp.db.unixodbc.devel
Message-ID <2850204.1214163357697.JavaMail.root@elwamui-darkeyed.atl.sa.earthlink.net>
Nick,

-----Original Message-----
>From: Nick Gorham <[email protected]>
>Sent: Jun 20, 2008 12:16 PM
>To: Igor Korot <[email protected]>, Development issues and topics for unixODBC <[email protected]>
>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>
>Igor Korot wrote:
>
>>Nick,
>>
>>-----Original Message-----
>>  
>>
>>>From: Nick Gorham <[email protected]>
>>>Sent: Jun 20, 2008 8:36 AM
>>>To: Igor Korot <[email protected]>
>>>Cc: Development issues and topics for unixODBC <[email protected]>
>>>Subject: Re: [unixODBC-dev] mySQL and SQLDriverConnect
>>>
>>>Igor Korot wrote:
>>>
>>>    
>>>
>>>>>>     
>>>>>>
>>>>>>          
>>>>>>
>>>>>By the way, when you say you explicitly call the non unicode function, 
>>>>>do you mean you call SQLDriverConnectA, becaue with UNICODE defined 
>>>>>SQLDriverConnect becomes SQLDreiverConnectW (as it does in windows)
>>>>>   
>>>>>
>>>>>        
>>>>>
>>>>retcode = SQLDriverConnect( m_hdbc, parentWnd, (SQLTCHAR FAR *)"DSN=test;", ...);
>>>>                                               ^^^^^^^^^^^^^^
>>>>
>>>>I am doing casting of the parameters.
>>>>In UNICODE version, this would become (SQLWCHAR FAR *).
>>>>
>>>>So, unless the linker is not smart, he should look at the proper signature of the
>>>>function.
>>>>
>>>> 
>>>>
>>>>      
>>>>
>>>Not entirly correct
>>>
>>>(SQLTCHAR FAR *)"DSN=test;"
>>>
>>>when UNICODE is defined, will create a SQLWCHAR * pointer, but the thing it points to will still be a char string;
>>>
>>>I think thats the problem, you are passing the address 8bit string into a function thats expecting a 16bit sequence of values. Casting the pointer to a pointer of another type will not alter the thing thats being pointed to.
>>>
>>>Remember C will do what you tell it to, even if thats not what you want it to do :-)
>>>    
>>>
>>
>>Ok, it is very easy to check. ;-)
>>It is morning here and I'm at work. When I come home, I will enable ODBC logging and run my
>>program. Hopefully you are right, I was just banging my head over nothing and simply passing:
>>"DSN=test;" without casting should fix the issue.
>>  
>>
>
>No, that sill wont work, you either need to pass  a wide string, or 
>force the use of the ansi function
>
>SQLWCHAR str[] = { 'D','S','N','='.''t','e','s','t',';',0 };
>SQLDriverConnect( ... str, SQL_NTS, ... );

Just tried this. Got an error IM002: "No DSN found", according to MSDN.
Do I need a semi-colon at the end of connection string?

>
>or
>
>SQLCHAR *str = "dsn=test;";
>SQLDriverConnectA( ..., str, SQL_NTS, ... );

Also tried. Got compiler error:

"error: invalid conversion from 'const char*' to 'SQLCHAR*'".

Thank you.

>
>-- 
>Nick Gorham
>Easysoft Limited
>http://www.easysoft.com, http://www.unixODBC.org
>

_______________________________________________
unixODBC-dev mailing list
[email protected]
http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.