[unixODBC-dev] (no subject)

Igor Korot ikorot at earthlink.net
Sat Nov 19 02:57:32 GMT 2005


Thank you, guys. It finally works.
Also, I would like to say that, whenever possible, I will use ODBCConfig, instead of going to correct, append or delete the DSN and/or the driver instances by hand.

Thank you.

-----Original Message-----
From: Igor Korot <ikorot at earthlink.net>
Sent: Nov 16, 2005 12:48 PM
To: Nick Gorham <nick at lurcher.org>, Development issues and topics for unixODBC <unixodbc-dev at easysoft.com>
Subject: Re: [unixODBC-dev] (no subject)

Nick, Stefan, and ALL,
Let me give you an example of what I mean by my problem and what I am looking for to do. I am attaching 2 files in the Microsoft Word format and the plain TXT format, because I know that somebody might not have the MS products on their machines.
I just feel it would be best to give an example of what I am looking for to do.
 
Thank you for taking so much time talking and explaining everything to me. Also, please forgive me my bad English if you find any problem with that. I am not a native English-speaking person...
 
Thank you.

-----Original Message-----
From: Nick Gorham <nick at lurcher.org>
Sent: Nov 16, 2005 5:20 AM
To: Igor Korot <ikorot at earthlink.net>, Development issues and topics for unixODBC <unixodbc-dev at easysoft.com>
Subject: Re: [unixODBC-dev] (no subject)

Igor Korot wrote:
> Nick, Stefan and others,
> When I earlier said that I have more work to, I meant that I need to find a function that will give me a list of DSN names for specified driver.
> On Windows I could easily do it as:

To try and bring this to a close, the following does exactly what you 
describe you want, with unixODBC and Windows. But it will only do this 
if your ini files are configured as unixODBC expects, if not then its 
not a fault in unixODBC, but in the ini files.

#include <stdio.h>
#include <sql.h>
#include <sqlext.h>

main()
{
     SQLHANDLE env;
     SQLRETURN ret;
     int result;
     unsigned char driverDesc[ 512 ];
     unsigned char attrib[ 512 ];
     unsigned char server[ 512 ];
     unsigned char desc[ 512 ];
     short slen, dlen;
     short descrLength = 512, attrLength = 512;

     ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env );
     ret = SQLSetEnvAttr( env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) 3, 0 );

     result = SQLDrivers( env, SQL_FETCH_NEXT, driverDesc,
              sizeof( driverDesc ), &descrLength, attrib, sizeof( attrib 
), &attrLength );
     while( result != SQL_NO_DATA_FOUND )
     {
         printf( "Driver: %s\n", driverDesc );
         result = SQLDataSources( env, SQL_FETCH_FIRST, server,
                 sizeof( server ), &slen, desc, sizeof( desc ), &dlen );
         while( result != SQL_NO_DATA_FOUND )
         {
             if ( strcmp( desc, driverDesc ) == 0 ) {
                 printf( "\tDSN: %s\n", server );
             }
             result = SQLDataSources( env, SQL_FETCH_NEXT, server,
                     sizeof( server ), &slen, desc, sizeof( desc ), &dlen );
         }
         result = SQLDrivers( env, SQL_FETCH_NEXT, driverDesc,
                     sizeof( server ), &descrLength, attrib, sizeof( 
attrib ), &attrLength );
     }
     ret = SQLFreeHandle( SQL_HANDLE_ENV, env );
}




More information about the unixODBC-dev mailing list