After iterating through data sources with SQLDataSources() and reaching the end (SQL_NO_DATA is returned), the next call with SQL_FETCH_NEXT will still return SQL_NO_DATA. However the MS documentation says: "If SQLDataSources is called with SQL_FETCH_NEXT immediately after it returns SQL_NO_DATA, it will return the first data source name" (i.e., it loops back to the beginning), and this is in fact the behaviour on Windows. (see: http://msdn.microsoft.com/en-us/library/ms711004%28VS.85%29.aspx under Comments).
I haven't tested, but this might be as simple as:
--- DriverManager/SQLDataSources.c 2008-06-30 18:40:48.000000000 +1000
+++ DriverManager/SQLDataSources.c 2010-10-26 16:28:34.000000000 +1100
@@ -289,6 +289,7 @@
object, sizeof( object )) != INI_SUCCESS )
{
ret = SQL_NO_DATA;
+ environment -> entry = 0;
}
else
{
--- DriverManager/SQLDataSourcesW.c 2003-10-31 05:20:45.000000000 +1100
+++ DriverManager/SQLDataSourcesW.c 2010-10-26 16:28:22.000000000 +1100
@@ -220,6 +220,7 @@
object, sizeof( object )) != INI_SUCCESS )
{
ret = SQL_NO_DATA;
+ environment -> entry = 0;
}
else
{