SQLConnect With Custom ODBC Driver

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: KalliMan (KalliMan_at_discussions.microsoft.com)
Date: 02/13/05


Date: Sun, 13 Feb 2005 05:45:03 -0800

Dear all,
I'm trying to write an ODBC Driver DLL. I register it with
SQLInstallDriverEx and Implement "ConfigDSN" and "SQLConnect". With
"SQLConfigDataSource" i register Some Data source( ds1 ), but if I try to
connect via "SQLConnect" ODBC's "SQLGetDiagRec" return "Driver Doesn't
support this function" !?!?.
I found my DSN ( ds1 )in ODBC Data sources in Control Panel, and when i open
it, ODBC shows an error message "Driver's ConfigDSN : Component not found in
registry". But in registry in "ODBCINST" I have "ConnectFunctions=YNN" which
mean that i support "ConfigDSN" !?!. The same situation after reinstal MDAC.
My DLL's funktions work fine if i load dll with "Afx/LoadLibrary".
What is Wrong?

Win2000 SP3, MDAC 2.8

--------------------
Here is my Driver String which i use to register my Odbc driver:
LPCTSTR pszDriver =
_T("MyDriver\0DRIVER=MyDriver.dll\0SETUP=MyDriver.dll\0SQLLevel=1\0FileUsage=0\0DriverODBCVer=01\0ConnectFunctions=YNN\0APILevel=2\0CPTimeout=60\0\0");

SQLInstallDriverEx(pszAttributes ,NULL, szLoc, FILENAME_MAX, &nLocLen,
ODBC_INSTALL_COMPLETE, &nUsageCount );
--------------------

Here is my sample code for Connection
----------------------
rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);

        rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0);

        rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);

        rc = SQLConnect(hdbc,(SQLCHAR*) "ds1", SQL_NTS, (SQLCHAR*) "", SQL_NTS,
                (SQLCHAR*) "", SQL_NTS);

----------------------

Regards :
KalliMan



Relevant Pages

  • ODBC SQLConnect
    ... I'm trying to write an ODBC Driver DLL. ... SQLInstallDriverEx and Implement "ConfigDSN" and "SQLConnect". ... "SQLConfigDataSource" i register Some Data source, ...
    (microsoft.public.data.odbc)
  • RE: ODBC dll files are crashing
    ... DllRegisterServer is a COM-oriented function intended to register COM classes ... Since SQLSRV32 is an ODBC driver and doesn't expose any ... your OS includes MDAC as its part to reinstall the OS or the latest Service ... > pro) and found that all of the .dll driver files were missing. ...
    (microsoft.public.data.odbc)
  • Re: ConfigDSN
    ... Can you be a little more explicit about what I need to do. ... > ConfigDSN will be implemented by the Setup DLL for the particular ODBC driver your DSN will use. ... i cannot figure out which LIB i need to link with. ...
    (microsoft.public.data.odbc)
  • Re: ConfigDSN
    ... ConfigDSN will be implemented by the Setup DLL for the particular ODBC driver your DSN will use. ... Read more about the ODBC API, starting with things like the SQLDataSources and SQLDrivers functions. ...
    (microsoft.public.data.odbc)