iodbc: Trying to get first program to run.

iodbc: Trying to get first program to run.

Post by Murray Todd William » Sun, 13 Dec 1998 04:00:00

I'm trying to get the simplest program to run under Linux using the
iODBC library.  I've got the following working:

  1. Both PostgreSQL (6.3) and MySQL are running on my Linux "server"
     computer, named "lust"
  2. I have created a database called "warehouse" under both db servers,
     added a table "user" and put a single sample record into it.  I've
     also created a userid "murray" under both servers.
  3. I have installed the Windows ODBC drivers on a Windows client
     computer AND accessed both servers via MS Excel, so I have proof
     that both servers are running, accept connections on their default
     ports, and accept the user "murray".
  4. I have installed iodbc, myodbc, and postgres-odbc on a client Linux
     computer.  All header files and libraries are in place.
  5. I can compile and run the following program without errors.
     printerror() is a quick and dirty function to print the return code
     "rc".  For all four functions it returns SQL_SUCCESS.

int main()
    rc = SQLAllocEnv(&henv);

    rc = SQLAllocConnect(henv, &hdbc);

    rc = SQLFreeConnect(hdbc);

    rc = SQLFreeEnv(henv);



Now, when I add the following right after the SQLAllocConnect function:

    rc = SQLConnect(hdbc, "warehouse", SQL_NTS, "merck", SQL_NTS,
"kilroy", SQL_NTS);

I get rc==SQL_ERROR, but when I printf the SQLError strings, I just get
NULL strings.

I'm assuming by the successful SQLAllocConnect that the specific ODBC
driver (for MySQL and PostgreSQL) are loading properly.  I think it's
just a matter of having the correct values in iodbc.ini.

Here's the question though: I've got about 5 iodbc.ini files spread
throught my directory structure.  Some in /usr/local/lib, one in
/usr/lib/iodbc/lib, one in the src directory, another in the docs
directory.  I don't know how to figure out which one the driver expects,
then I'm not sure how to diagnose which entries are incorrect because
I'm getting no useful error messages back.

Does anyone have any suggestions?

Murray Todd Williams