Re: ODBC32.DLL access violation during DriverConnect

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



The following MSDN article defines the ODBC interface conformance
requirements for ODBC drivers.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbccore_interface_conformance.asp

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Regards,
Uwa Agbonile[MSFT]

"James Foster" <JamesFoster@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:593A97C6-17C3-4FB7-871C-51AC5DE63F12@xxxxxxxxxxxxxxxx
> I'm writing an ODBC Driver on Windows XP SP2 with Visual C++ version
7.1.3088
> and testing it with ODBCTE32.EXE based on the steps described at
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcstep_1__connect_to_the_data_source.asp.
>
> When I execute any of the connect functions, I see the following proper
> things happen:
> (1) DllMain() is called with DLL_PROCESS_ATTACH;
> (2) SQLAllocHandle() is called with SQL_HANDLE_ENV;
> (3) SetEnvAttr() is called with SQL_ATTR_ODBC_VERSION; and
> (4) SQLAllocHandle() is called with SQL_HANDLE_DBC.
>
> At this point if I call SQLConnect() and pass in my driver name or call
> SQLDriverConnect() and have the system query for the data source, I get
the
> following access violation:
>
> Unhandled exception at 0x74326c92 (odbc32.dll) in odbcte32.exe:
> 0xC0000005: Access violation writing location 0x00e00d90.
>
> odbc32.dll!_VFreeErrors@4() + 0xa8
> odbc32.dll!_AddError@24() + 0xe
> odbc32.dll!_PostDriverManagerError@12() + 0x1c
> odbc32.dll!_SQLInternalDriverConnectW@36() + 0xf3de
> odbc32.dll!_SQLDriverConnectW@32() - 0x5cc6
> odbc32.dll!_SQLDriverConnect@32() + 0x125
>
> QUESTION: How can I figure out what the Driver Manager is doing? As far as
I
> can tell, the tracing feature only traces between the (test) application
and
> the Driver Manager, with no tracing of the Driver calls. Is that correct?
>
> Following is the Driver Manager trace output:
>
> odbcte32 764-bb8 ENTER SQLAllocHandle
> SQLSMALLINT 1 <SQL_HANDLE_ENV>
> SQLHANDLE 00000000
> SQLHANDLE * 00089148
>
> odbcte32 764-bb8 EXIT SQLAllocHandle with return code 0
(SQL_SUCCESS)
> SQLSMALLINT 1 <SQL_HANDLE_ENV>
> SQLHANDLE 00000000
> SQLHANDLE * 0x00089148 ( 0x003b18d8)
>
> odbcte32 764-bb8 ENTER SQLSetEnvAttr
> SQLHENV 003B18D8
> SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
> SQLPOINTER 0x00000003
> SQLINTEGER -3
>
> odbcte32 764-bb8 EXIT SQLSetEnvAttr with return code 0
(SQL_SUCCESS)
> SQLHENV 003B18D8
> SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
> SQLPOINTER 0x00000003 (BADMEM)
> SQLINTEGER -3
>
> odbcte32 764-bb8 ENTER SQLAllocHandle
> SQLSMALLINT 2 <SQL_HANDLE_DBC>
> SQLHANDLE 003B18D8
> SQLHANDLE * 00089408
>
> odbcte32 764-bb8 EXIT SQLAllocHandle with return code 0
(SQL_SUCCESS)
> SQLSMALLINT 2 <SQL_HANDLE_DBC>
> SQLHANDLE 003B18D8
> SQLHANDLE * 0x00089408 ( 0x003b19a0)
>
> odbcte32 764-bb8 ENTER SQLDriverConnectW
> HDBC 003B19A0
> HWND 000307D0
> WCHAR * 0x74329A38 [ -3] "******\ 0"
> SWORD -3
> WCHAR * 0x74329A38
> SWORD 2
> SWORD * 0x00000000
> UWORD 2 <SQL_DRIVER_PROMPT>
>
>
> If instead of SQLDriverConnect(), I call SQLBrowseConnect(), the Driver
> Manager returns state IM001 "Driver does not support this function."
>
> QUESTION: How can I determine which function it wants but can't find? I've
> created stubs and exported them for all the core functionality just so I
can
> put a breakpoint in to see what is called. Nothing of mine is being called
> besides what is listed above.
>
>
> I understand that building an ODBC driver is complex, but I'm unable to
> figure this one out. Any help or suggestions would be much appreciated.
>
> James Foster


.