[Gambas-devel] Change to gb.db.odbc to use ODBC Connection Strings.

ML d4t4full at ...176...
Mon Sep 14 17:41:47 CEST 2015


Benoît,

Continuing here as you requested.
I found the problem in th driver that causes it to return 0 instead of 
-1 in the RowCount. The offending line and my patch:

   //20150914 - zxMarce: Do NOT mark the STMT as Scrollable; it makes 
SQLRowCount always return 0 rows instead of -1.
   //retcode = SQLSetStmtAttr(odbcres->odbcStatHandle, 
SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0);
   retcode = SQLSetStmtAttr(odbcres->odbcStatHandle, 
SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, 0);

It just needed a constant change from SQL_SCROLLABLE to SQL_NONSCROLLABLE.
Looks like the intention was to make a proper driver, with forward and 
back scroll, but for some reason it was not completed.

Now the problem propagates to Result.MoveNext and Result.Available. They 
loop forever, even when there's no more data to fetch.
I made a further change in query_fill (removed a GB.Error that raised 
'ODBC_NO_MORE_DATA' and added a return TRUE), but that did not get 
.MoveNext or .Available fixed:

   if((retcode2 == SQL_NO_DATA_FOUND) || (retcode2==SQL_NO_DATA))
   {
     //GB.Error("ODBC_END_OF_DATA!"); //20150914 - zxMarce: Removed so 
.MoveNext and .Available work?
     return TRUE; //20150914 - zxMarce: Try to make .MoveNext fail when 
no more data
   }

I think when we (you?) fix these problems, we will finally have a 
working Gambas ODBC subsystem.

Thanks,

*On 2015-08-27 15:06, Benoît Minisini wrote:*
> *Le 27/08/2015 20:03, Benoît Minisini a écrit :*
>> *Le 27/08/2015 19:14, zxMarce a écrit :*
>>> Benoît,
>>>
>>> No problem, I know you're not the author of the ODBC component.
>>> Precisely, one of my modifications was adding an IF to call either 
>>> *SQLConnect* (normal method so far) or *SQLDriverConnect*; this is 
>>> the new call, and does not use .User, .Password nor .Name, as they 
>>> can all be set in the connection string.
>>> I added, then, an IF and a FUNCTION.
>>> This is the IF, in main.c's open_database:
>>> ... And this is the function that new IF calls:
>>> Thanks,
>>> zxMarce.
>> Please post directly to the developer mailing-list. nabble.com makes 
>> your mail unreadable by removing pictures.
>> Or don't post pictures. Post the code as text!
> If your function (is_host_a_connstring) returns a boolean value, you 
> can use 'bool' as return datatype.
> If you are testing a boolean value, writing that:
>     if (xxx == TRUE)
> is not needed. Just write:
>     if (xxx)
> Regards,
--
zxMarce.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20150914/577293c7/attachment.html>


More information about the Devel mailing list