MS ODBC + MySQL + Borland BCC55 Compiler


2005-01-25 07:09:24 AM
cppbuilder93
Hello here's a small part of simple program I'm going write to connect with
MySQL server via ODBC (Windows).
----------------------------------------------------------------------------
----
include <iostream.h>//Standard i/o libarary
#include <iomanip.h>//To manipulate input strings setw()....
#include <string.h>//string operations strcpy()...
//To get ODBC functionality
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
int main(){
char rhost[50], ruser[20], rpassword[20], rdatabase[20];
cout << "\nRemote host? ";
cin>>setw(50)>>rhost;
cout << "User? ";
cin>>setw(20)>>ruser;
cout << "Password? ";
cin>>setw(20)>>rpassword;
cout << "Database to connect? ";
cin>>setw(20)>>rdatabase;
cout << "\nReceived info:\n" << "Host: " << rhost << endl << "User: " <<
ruser << endl;
cout << "Password: " << rpassword << endl << "Database: " << rdatabase <<
endl;
cout << endl << "Connecting..." << endl;
//SQL Connection Part
SQLHENV henv1; //Environment handler
SQLHDBC hdbc1; //Connection handler
SQLHSTMT hstmt; //Statement handler
//Create environment for SQL operations
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv1);
//Select database driver
SQLConnect(hdbc1, rhost, strlen(rhost), ruser, strlen(ruser), rpassword,
strlen(rpassword));
.
.
.
}
----------------------------------------------------------------------------
----
Don't know why but it doesn't want to compile: "bcc32 file.cpp" gives
Unresolved
extternal 'SQLAllocHandle' from file.obj and prints the same errof for each
of ODBC/SQL functions.
I tried to do it in two steps first called a bcc32 -c file.cpp to get
file.obj
then used an incremental linker "ilink32 file.obj,,,odbc32.lib" - doesn't
work
either. Creates a 2KB non w32 application code. Also tried to link the obj
with
import32.lib, cw32.lib and myodbc3.lib to create executable - the result was
the executable has been created without errors but it doesn't want to run
-generats some memory violations on w2k.
Can You help me tell?