| Bug #10334 | sqldriverconnect fails with a system (global) dsn | ||
|---|---|---|---|
| Submitted: | 3 May 2005 13:54 | Modified: | 26 Jul 2007 0:26 |
| Reporter: | eid0 | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S1 (Critical) |
| Version: | 3.51.11 and 3.51.10 | OS: | Windows (win32) |
| Assigned to: | CPU Architecture: | Any | |
[3 May 2005 13:54]
eid0
[15 May 2005 8:49]
Vasily Kishkin
Sorry. But I could't repeat that bug. I created test program and it worked fine with DSN.
[15 May 2005 9:56]
eid0
for Vasily Kishkin: Hi, did you call SQLDriverConnect with (UCHAR *) dataSource = "DSN=nameofglobaldsn" and nothing more in the string? To me it always returns -1, downgrading myodbc sqldriverconnect works ok. Thankyou
[16 May 2005 5:20]
Vasily Kishkin
Probably there is a problem with SQL_DRIVER_COMPLETE in SQLDriverConnect(). I assigned the bug to developer.
[26 Jul 2007 0:26]
Jim Winstead
As long as a valid window handle is provided as the second argument to SQLDriverConnect(), I have no problem using SQLDriverConnect(..., SQL_DRIVER_COMPLETE) on Microsoft Windows using 3.51.17. It uses GetForegroundWindow() to retrieve a window handle even though this is a console application. I've tested with both a user DSN and a system DSN.
Here's my test program:
#include <windows.h>
#undef UNICODE
#include <stdlib.h>
#include <sql.h>
#include <sqlext.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
SQLRETURN rc;
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR in[500], out[500];
SQLSMALLINT len;
rc= SQLAllocEnv(&henv);
if (!SQL_SUCCEEDED(rc))
exit(1);
rc= SQLAllocConnect(henv, &hdbc);
if (!SQL_SUCCEEDED(rc)) {
SQLRETURN lrc;
SQLCHAR sqlstate[6], message[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER native;
SQLSMALLINT messagelen;
lrc= SQLGetDiagRec(SQL_HANDLE_DBC, hdbc, 1, sqlstate, &native, message, sizeof(message), &messagelen);
if (SQL_SUCCEEDED(lrc))
fprintf(stderr, "state: %6s, message: %*s (%d)\n", sqlstate, messagelen, message, native);
exit(1);
}
sprintf((char *)in, "%s", "DSN=sysneedinfo");
rc= SQLDriverConnect(hdbc, GetForegroundWindow(), in, SQL_NTS, out, sizeof(out), &len, SQL_DRIVER_COMPLETE);
if (!SQL_SUCCEEDED(rc)) {
SQLRETURN lrc;
SQLCHAR sqlstate[6], message[SQL_MAX_MESSAGE_LENGTH];
SQLINTEGER native;
SQLSMALLINT messagelen;
lrc= SQLGetDiagRec(SQL_HANDLE_DBC, hdbc, 1, sqlstate, &native, message, sizeof(message), &messagelen);
if (SQL_SUCCEEDED(lrc))
fprintf(stderr, "state: %6s, message: %*s (%d)\n", sqlstate, messagelen, message, native);
exit(1);
}
fprintf(stderr, "out: %*s\n", len, out);
return 0;
}
