OpenDBX

for Project:

Open Database abstraction layer

Register as a new user

Task #24 — ODBC problem in windows with certain options

Attached to Project — OpenDBX
Opened by Mariano Martinez Peck (MarianoPeck) - Thursday, 15 Oct 2009, 10:10pm
Last edited by Norbert Sendetzky (nose) - Thursday, 3 Dec 2009, 10:02pm
Bug Report Medium
Backend Normal
Closed 1.4.x
Norbert Sendetzky (nose) 1.4.x
Windows 100% complete
Norbert: I need to make ODBC to work in Windows. I am trying your dlls from 1.4.4 but i am still having the same problem I had at that time. It doesn't matter which ODBC driver I use, I always have the same problem. It is even before OpenDBX uses the DSN I said in "host" variable.

I ALWAYS have the error "option type out of range" (translated from spanish to english). The problem seems to be:

-2719: Option type out of range

ODBC Error. A function was called with an invalid value for the argument fOption (e.g. the functions SQLSetConnectOption() or SQLTransact()).

The problem is odbc_odbx_bind, where you do:

gen->err = SQLSetConnectAttr( gen->conn, SQL_DEFAULT_TXN_ISOLATION, (SQLPOINTER) SQL_TXN_READ_COMMITTED, SQL_IS_UINTEGER );
if( !SQL_SUCCEEDED( gen->err ) )
{
return -ODBX_ERR_BACKEND;
}


when I could put the printf that time, I got this values

SQL_TXN_READ_COMMITTED: 2
SQL_IS_UINTEGER: -5

I would appreciate you give me some more lines to print everything you need.

The thing is that as this line is BEFORE the SQLConnect I ALWAYS have that error.

I give you more information: I create a ODBC datasource to an SQL Server database and the ODBC test is ok. It uses the driver C:\WINDOWS\system32\sqlsrv32.dll and the C:\WINDOWS\system32\odbc32.dll. If I remove sqlsrv32.dll and run this test, I have an error. Then I run the OpenDBX tests and I got what I told you. Look at the screenshot I attach. There you can see the specification of the datasource, the successfully result of the test, and the failure of opendbx. The message is in spanish.


But when I run the OpenDBX tests, the ODBC it is using is C:\WINDOWS\system32\odbc.dll (not C:\WINDOWS\system32\odbc32.dll). In addition, I can the test even removing sqlsrv32.dll or odbc32.dll and there is no dll error. So...those dlls are not being used. Anyway, odbc32.dll and odbc.dll are exactly the same.

Even weird...if I remove odbc.dll (whih is needed) I get the famous windows popup saying he cant find the dll but after pressing "ok", openDBX continues and there is where I get a problem I told you. This is weird, because after a problem like that one, it should exit, not continue....

I am completely lost.

I even took a clean PC but I have the same problem.

Thanks

Mariano

Closed by  Norbert Sendetzky (nose)
Date:  Saturday, 5 Dec 2009, 12:14pm.
Reason for closing:   Fixed
Additional comments about closing:  Will be part of OpenDBX 1.4.5

Comments (5) | Attachments (0) | Related Tasks (0/0) | Notifications (2) | Reminders (0) | History |

Comment by Mariano Martinez Peck - Thursday, 15 Oct 2009, 10:10pm

Norbert said:

I've tested myself and got the same error with MinGW odbc.dll. The problem is
that it doesn't seem to support the "read commited" isolation level.
Furthermore, it doesn't seem to support another option as well. I have to do
some investigations to see how we can work around this.

Comment by Stefan Kapusniak - Saturday, 21 Nov 2009, 2:40pm

I've been poking about with this trying to get a SQL Server 2008 Express connection to work with SqueakDBX, and I think the problem is that SQL_DEFAULT_TXN_ISOLATION is a read only property just for getting the default. To actually set the isolation level we want to use SQL_TXN_ISOLATION.

Similarly, it looks like SQL_ATTR_ANSI_APP which is set further on, is another read only one, and that if you want Unicode you have to call Unicode specific ODBC functions. At least on Windows.

Commenting out the setting of SQL_ATTR_ANSI_APP, and switching SQL_DEFAULT_TXN_ISOLATION to SQL_TXN_ISOLATION, gets me past the connection setup, and I can then make a connection in SqueakDBX (on Pharo).

Alas I can't get any further than that as everything, is the image then hangs when I try to send SQL on the connection. So possibly still some problems to go.

Comment by Stefan Kapusniak - Saturday, 21 Nov 2009, 4:24pm

Okay, I can unwedge my image by additionally switching the setting
of SQL_ATTR_ASYNC_ENABLE in odbc_odbx_bind, to SQL_ASYNC_ENABLE_OFF
instead of the current SQL_ASYNC_ENABLE_ON.

That gives 95/96 SqueakDBX core test passes for the ODBC backend
with MSSQL.

However, I really rather suspect this is not the way to go, since presumably it means that the calls are going to block for the
duration each query...?

Comment by Norbert Sendetzky - Tuesday, 1 Dec 2009, 7:58am

Thanks for the hints. Switching SQL_DEFAULT_TXN_ISOLATION to SQL_TXN_ISOLATION is the easy part, the ANSI/UTF-8 stuff is a bigger problem.

Do you have any idea why using SQL_ATTR_ASYNC_ENABLE has such an effect? Is this specific to Squeak or do you also get the same result when using the OpenDBX directly (e.g. by running the OpenDBX test suite)?

Comment by Norbert Sendetzky - Thursday, 3 Dec 2009, 10:01pm

I did some more researching and found out that the UTF-16 ODBC functions (e.g. SQLConnectW()) isn't needed to do UTF-8, so I've disabled SQL_ATTR_ANSI_APP.

Furthermore, I've removed the lines setting SQL_ATTR_ASYNC_ENABLE as it doesn't work using Windows ODBC like you've written. Maybe we find out later what is the problem but not setting this option is not critical.

Now, the ODBC backend also works for me on WinXP and I've committed the changes already to the SVN stable branch (rev 299). They will be part of OpenDBX 1.4.5

Thanks for your help