1. ODBCEU - Matt L.
- Posted by Jonas Temple <jktemple at yhti.net> Mar 27, 2002
- 395 views
Hey Matt, Just dusted off the odbceu include. We're looking at doing some inserts into a DB2 table and we thought ODBC might be one way to go. In any event, on Win2000 Pro the runDirectODBC function failed with an invalid token message. I tracked it down to the following statement: ok = w32Func( SQLExecDirect, { hs, h_ptr, length( sql ) + 1}) which I changed to: ok = w32Func( SQLExecDirect, { hs, h_ptr, length( sql )}) and it worked. The MSDN site said that the third parm should be the length of the second but didn't specify if the length of the actual statement or the length of the null-term string. It worked fine on Win95/98 so I wonder if they changed something....hmmm. Also, I noticed way back when that when you use dataSourcesODBC there is on dsn listed twice. I saw this on Win95/98/2000 but never sat down to look at it. The loop where you load the dsns is: while state = SQL_SUCCESS do --not find( state, { SQL_NO_DATA, SQL_ERROR }) do state = w32Func( SQLDataSources, { getHandleODBC(henv), SQL_FETCH_NEXT, server, SQL_MAX_DSN_LENGTH, nl1, desc, SQL_MAX_DSN_LENGTH*2,nl2}) dsn &= { {peek_string( server ), peek_string( desc ) }} end while The problem is the last dsn is loaded twice to the sequence. I fixed this with: while state = SQL_SUCCESS do --not find( state, { SQL_NO_DATA, SQL_ERROR }) do state = w32Func( SQLDataSources, { getHandleODBC(henv), SQL_FETCH_NEXT, server, SQL_MAX_DSN_LENGTH, nl1, desc, SQL_MAX_DSN_LENGTH*2,nl2}) if state = SQL_SUCCESS then dsn &= { {peek_string( server ), peek_string( desc ) }} end if end while FYI.... Jonas