[freetds] 0.83.dev.20100507 and Visual Studio 2010

Harry Sfougaris hsfougaris at gmail.com
Sat May 8 16:53:01 EDT 2010



On 08 Μαϊ 2010, at 9:05 μ.μ., Paul Thurston wrote:

> Harry:
> 
> Are you using dblib and connecting to SQLServer?
Yes I am. (dblib to Sql Server 2008).

Now for the bad news: my Visual Studio C++ Console app is not working.
It was quietly dying before, which I only realized after adding some code to retrieve data.

There seem to be 2 issues: an unable to open socket error, and the error handlers not getting installed ( I think as they're not being called), so the program just crashes.
This is after calling dbopen(), and it is in tdserror(...)
The actual message is "Unable to open socket" (by inspecting the variable msg) but the program crashes when trying to call
rc = tds_ctx->err_handler(tds_ctx, tds, &msg);
 
Qt seems to link fine now, but also quietly dies - I guess it's for the same reason.
Maybe it's the socket libraries I'm linking?
I used WS2_32.lib , odbc32.lib, odbccp32.lib (and of course the other 3 libraries).

I tried both Win32 and x64 builds - same results. And of course I do have connectivity to my server.

My freetds.log mentions the following:
23:46:10.023 3268 (log.c:190):Starting log file for FreeTDS 0.65
	on 2010-05-08 23:46:10 with debug flags 0xffff.
23:46:10.023 3268 (iconv.c:78):Using trivial iconv
23:46:10.023 3268 (iconv.c:197):names for ISO-8859-1: ISO-8859-1
23:46:10.023 3268 (iconv.c:197):names for UTF-8: UTF-8
23:46:10.023 3268 (iconv.c:197):names for UCS-2LE: UCS-2LE
23:46:10.023 3268 (iconv.c:197):names for UCS-2BE: (null)
23:46:10.023 3268 (iconv.c:363):iconv to convert client-side data to the "CP1253" character set
23:46:10.023 3268 (iconv.c:477):tds_iconv_info_init: use memcpy to convert "CP1253"->"UCS-2LE"
23:46:10.038 3268 (net.c:210):Connecting to 10.1.1.11 port 1433 (TDS version 8.0)
23:46:14.176 3268 (util.c:334):tdserror(00271C30, 00277A10, 20008, 0)
23:46:14.176 3268 (dblib.c:7782):dbperror(00277118, 20008, 0)
23:46:14.176 3268 (dblib.c:7835):20008: "Unable to open socket"
23:46:14.176 3268 (dblib.c:4781):default_err_handler 00277118, 9, 20008, 0, 0123DD40, 00277FE023:46:14.176 3268 (dblib.c:4747):dbdead(00277118) [dead]
23:46:14.176 3268 (dblib.c:7856):"Unable to open socket", client returns 0 (INT_EXIT)
23:46:14.176 3268 (dblib.c:7903):FreeTDS: db-lib: exiting because client error handler returned 0 for msgno 20008

(the FreeTDS 0.65 strikes me as very odd, as I am working with 0.82)

My program is dead simple:
int main(int argc, char **argv)
{
    LOGINREC *login;
    RETCODE erc;
	DBPROCESS *dbproc;
	dberrhandle(syb_err_handler);
    dbmsghandle(syb_msg_handler);

    if (dbinit() == FAIL) {
            return -1;
    }

    if ((login = dblogin()) == NULL) {
            return =2;
    }

    dbsetifile((char*)"C:\\Users\\harry.MISSIRIAN\\freetds.conf");

    DBSETLUSER(login, "***" );
    DBSETLPWD(login,  "***" );
    DBSETLCHARSET(login, "CP1253" );
    if ((dbproc = dbopen(login, "sql" )) == NULL) {
            return -3;
    }


and my freetds.conf is like this:
[sql]
	host = 10.1.1.11
	port = 1433
	tds version = 8.0
	dump file = C:\Users\harry.MISSIRIAN\freetds.log
	debug flags = 0xffff

Harry




More information about the FreeTDS mailing list