For the last couple of weeks I been struggling with implementing custom odbc functions. Here is where I am . I managed to implement setup functions, and everything works ok. I can create DSN, and it will call my ConfigDSN function and it will register my ODBC in registry under ODBC.INI and it will set driver key and value that is pointing to my customOdbcApi.dll.
Problem is that when I try to connect to my DSN, it does notcall any of the functions,like SQLConnect.
This is response I got when I try to connect to my "AiPandaOdbc"
But In my function I implemented a message dialog that should pop up and I return 0 from the function not -2
What I checked so far:
Path in registry is correct, it points to the odbcDriver.dll
I added .def file in which I added all of the functions that I want to export.
Only thing that is very interesting is that If I put MessageBox call in DllMain, then messsage box shows, so my dll is 100% recongnized.
What Am I missing or forgoting to add so that my functions get called ?
EDIT: I also tried with console application but still nothing, SQLAllocHandle returns 0 but SQLConnect returns -1
EDIT 2:
I added the #undef UNICODE, so I make sure that he calls SQLConnect instead of SQLConnectW. But problems still remains. Still my SQLConnect doesnt get called.
<html>
<head></head>
<body>
<h1>ODBC TRACE LOG</h1>
<textarea style="width:90%;height:900px;">
ConsoleApplicat 3120-6500 ENTER SQLAllocHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 0x00000000
SQLHANDLE * 0x00A5C138
ConsoleApplicat 3120-6500 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 0x00000000
SQLHANDLE * 0x00A5C138 ( 0x00DD7938)
ConsoleApplicat 3120-6500 ENTER SQLSetEnvAttr
SQLHENV 0x00DD7938
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 3 <SQL_OV_ODBC3>
SQLINTEGER 0
ConsoleApplicat 3120-6500 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 0x00DD7938
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 3 <SQL_OV_ODBC3>
SQLINTEGER 0
ConsoleApplicat 3120-6500 ENTER SQLAllocHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 0x00DD7938
SQLHANDLE * 0x00A5C13C
ConsoleApplicat 3120-6500 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 0x00DD7938
SQLHANDLE * 0x00A5C13C ( 0x00DD79B8)
ConsoleApplicat 3120-6500 ENTER SQLConnectW
HDBC 0x00DD79B8
WCHAR * 0x00DD04D0 [ -3] "AiPandaODBC\ 0"
SWORD -3
WCHAR * 0x73382440 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x73382440 [ -3] "******\ 0"
SWORD -3
ConsoleApplicat 3120-6500 EXIT SQLConnectW with return code -1 (SQL_ERROR)
HDBC 0x00DD79B8
WCHAR * 0x00DD04D0 [ -3] "AiPandaODBC\ 0"
SWORD -3
WCHAR * 0x73382440 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x73382440 [ -3] "******\ 0"
SWORD -3
DIAG [IM001] [Microsoft][ODBC Driver Manager] Driver does not support this function (0)
ConsoleApplicat 3120-6500 ENTER SQLFreeHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 0x00A5C138
ConsoleApplicat 3120-6500 EXIT SQLFreeHandle with return code -2 (SQL_INVALID_HANDLE)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 0x00A5C138
ConsoleApplicat 3120-6500 ENTER SQLFreeHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 0x00A5C13C
ConsoleApplicat 3120-6500 EXIT SQLFreeHandle with return code -2 (SQL_INVALID_HANDLE)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 0x00A5C13C
</textarea>
</body>
</html>
For some reason he keeps calling SQLConnectW even though I have put #undef UNICODE
EDIT - I tried with adding the SQLConnectW function and exporting it, but still nothing.
Either call SQLConnectW and pass actual SQLWCHAR DSN string, or Call SQLConnectA to explicitly call the ANSI function, or undefine UNICODE when building code (add #undef UNICODE to top of source) to prevent the call to SQLConnect from being quietly mapped to SQLConnectW.
I am guessing you added the cast to SQLWCHAR* to prevent the compiler from complaining which is the clue that SQLConnect is not being called.
I managed to solve it. I implemented all functions and it worked
User contributions licensed under CC BY-SA 3.0