KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Unable to connect to 4D SQL Server with iodbctest
PRODUCT: 4D Developer | VERSION: 11 | PLATFORM: Mac OS X
Published On: October 24, 2007

The iODBC Framework includes a command line application called "iodbctest" that can be used to connect to ODBC data sources. If you use this application to connect to a 4D v11 SQL database you may find that it is not responsive. This is because of a bug in iodbctest.

The iodbctest application calls the ODBC function "SQLDriverConnect" with the argument SQL_DRIVER_PROMPT. This argument is used to specify that the ODBC driver being connected to should prompt the user for additional information if anything is missing from the connection string, for example if a user name was not specified. However, it is the responsibility of the calling application, in this case iodbctest, to provide a valid window handle to the ODBC driver so that the driver has a window in which to display its dialog requesting the information. Unfortunately the iodbctest application provides no such window handle (it passes 0 for the pointer) so the connection fails.

To fix this problem.

  1. Download the iODBC source from:

    http://www.iodbc.org/index.php?page=downloads/index
  2. Extract libiodbc-3.52.6.tar.gz (note that the file name may be different as the version changes).
  3. Inside the "libiodbc-3.52.6" folder is a folder called "samples". This folder includes the source code for iodbctest ("iodbctest.c") as well as the necessary make files.
  4. Edit the "ODBC_Connect" function in "iodbctest.c", around line 300 and replace both instances of SQL_DRIVER_PROMPT with SQL_DRIVER_NOPROMPT.
  5. Install Apple Xcode Tools (I used 2.4.1).
  6. Build a new version of iodbctest with the command:

    make -f Makefile.sample all


When you execute the new iodbctest make sure to prepend it with ./ otherwise the old one on the system path (from the iODBC installer) will be used. I.e.:

./iodbctest

With these changes you should be able to connect to a 4D v11 SQL database and query the data from iodbctest.