[unixODBC-support] SQL_INVALID_HANDLE error

Martin J. Evans martin.evans at easysoft.com
Fri Apr 21 09:11:25 BST 2006


On 20-Apr-2006 Marshall Wood wrote:
> What is it?????
> 
> I think it might have something do with my connection string, but I am
> unsure if that is true.
> 
> 
> char szDSN[] = "ODBC:FILETDS";
> retcode = SQLConnect(hDbConn, (UCHAR *)szDSN, SQL_NTS, (UCHAR *)szUID,
> SQL_NTS, (UCHAR *) szAuthStr, SQL_NTS);
> 
> I have tried
> 
> char szDSN[] = "FILETDS";
> retcode = SQLConnect(hDbConn, (UCHAR *)szDSN, SQL_NTS, (UCHAR *)szUID,
> SQL_NTS, (UCHAR *) szAuthStr, SQL_NTS);
> 
> I'm running out of places to ask :)

This is as good a place as you'll get.

Where did hDbConn come from? It means the hDBConn you passed in to SQLConnect
is not a valid connection handle and has nothing to do with the dsn. It should
be a handle returned from SQLAllocHandle e.g.

SQLHENV henv;
SQLHDBC hdbc;

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
SQLSetEnvAttr(to set odbc version required)
SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
SQLConnect(hdbc, ............)

BTW, I doubt you have a DSN called ODBC:FILETDS it is more likely FILETDS (your
second example).

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com




More information about the unixODBC-support mailing list