Hi there,

I'm building a CGI application in C, using ODBC.
Since ODBC is new to me I wrote this test program to check the current DBMS and get the 'feeling' for it.

The problem is I can't link the created object with the ODBC functions.

Down below you'll find:
1) The compile/linker listing.
2) The source code to my program.

I red in other messages in this forum about prototyping the functions in all the sources of you're program.
Except this is a linking error using a DLL (ODBC) and a library (ODBC32.lib).

So please help me out, or point me to a good "Fundamentals of linking DLL's and LIB's" Tutorial.

Hopie Thanks and Peace

Dennis

=== (1) === (1) === (1) === (1) === (1) === (1) ===

> C:\borland\bcc55\bin\ILink32 @MAKE0000.@@@
> Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
! Error: Unresolved external '_SQLAllocHandle' referenced from C:\DATABASE\T
* EST\ODBC_CGI\ODBC001.OBJ
! Error: Unresolved external '_SQLConnect' referenced from C:\DATABASE\TEST\
* ODBC_CGI\ODBC001.OBJ
! Error: Unresolved external '_SQLDisconnect' referenced from C:\DATABASE\TE
* ST\ODBC_CGI\ODBC001.OBJ
! Error: Unresolved external '_SQLFreeConnect' referenced from C:\DATABASE\T
* EST\ODBC_CGI\ODBC001.OBJ
! Error: Unresolved external '_SQLFreeEnv' referenced from C:\DATABASE\TEST\
* ODBC_CGI\ODBC001.OBJ
>
> ** error 2 ** deleting .\ODBCCGI
---- Make had errors. Right click error line to open file.

=== (2) === (2) === (2) === (2) === (2) === (2) === (2) ===

/*---------------------------------------------------------------------------*/
/* Program : Check ODBC */
/* Author : D.M. de Klerk */
/* Date : 16 november 2001 */
/*---------------------------------------------------------------------------*/

/* I tried using these defines (Got them from the headers) */

// #define ODBCVER 0x350
// #define RC_INVOKED

// #define SQL_SUCCESS 0
// #define SQL_SUCCESS_WITH_INFO 1
// #define SQL_NTS (-3)
// #define SQL_HANDLE_ENV 1
// #define SQL_HANDLE_DBC 2
// #define SQL_HANDLE_STMT 3
// #define SQL_HANDLE_DESC 4
// #define SQLHDBC long
// #define SQLHENV long
// #define SQLRETURN short
// #define SQL_DBMS_VER 18
// #define SQLUCHAR char*

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

#define STR_LEN 30

SQLHENV henv; /* Environment Handle */
SQLRETURN rc; /* Return Code */
SQLHDBC hdbc; /* Database Connectoion Handle */
SQLUCHAR info[STR_LEN]; /* Info String for SQLGetInfo */

/*- Main Procedure -*/

main()
{
printf("Content-Type: text/html/n/r/n/r/n");
printf("<HTML><HEAD></HEAD><BODY>");

/* Allocate Environment Handle */
rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&hen v);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
{
printf("Environment Handle Created Succesfully/n");
}
else
{
printf("Environment Handle Could Not Be created/n");
return 0;
}

/* Allocate connection handle */
rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
{
printf("Connection Handle Created Succesfully/n");
}
else
{
printf("Connection Handle Could Not Be Made/n");
return 0;
}

/* Connect to the data source */
rc = SQLConnect(hdbc, "database.mdb", SQL_NTS, "", SQL_NTS, "", SQL_NTS);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
{
printf("Database connection made succesfully/n");
}
else
{
printf("Databse connection could not be made/n");
return 0;
}

/* Get current DBMS version */
rc = SQLGetInfo(hdbc, SQL_DBMS_VER, &info, STR_LEN, NULL);
if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO)
{
printf("Current DBMS Version Obtained Succesfully, using NULL/n");
}
else
{
printf("Current DBMS Version Could Not Be Obtained, using NULL/n");
return 0;
}


printf("<BR><BR>");

printf("Current DBMS version is : %s\n", info);
printf("</BODY></HTML>");

/* Free All Handle + Disconnect From DataSource */
SQLDisconnect(hdbc);
SQLFreeConnect(hdbc);
SQLFreeEnv(henv);
return 0;
}