the correct one should be SA_ODBC_CLIENT which is for SQL Server connections.
#include <cstdio> // for printf
#include <SQLAPI.h> // main SQLAPI++ header
#include <iostream>
int main(int argc, char* argv[])
{
SAConnection con; // create connection object
try
{
// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC
con.Connect(
"test", // database name
"tester", // user name
"tester", // password
SA_ODBC_Client);
printf("We are connected!\n");
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect();
printf("We are disconnected!\n");
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("%s\n", (const char*)x.ErrText());
}
return 0;
}
You know, another story just started to play as soon as this bug was identified.
Quote
g++ -c -Wall -O2 -DNDEBUG -I/usr/lib/SQLAPI/include -o dbConnection.obj dbConnection.cpp
bash-3.1# g++ dbConnection.obj -o dbConnection -L/usr/lib/SQLAPI/lib -s -lsqlapi -lc -lm -lcrypt -ldl
bash-3.1# export LD_LIBRARY_PATH=/usr/lib/SQLAPI/lib
bash-3.1# ./dbConnection
libiodbc.so: cannot open shared object file: No such file or directory
libiodbc.so.3: cannot open shared object file: No such file or directory
libiodbc.so.2: cannot open shared object file: No such file or directory
libodbc.so: cannot open shared object file: No such file or directory
libodbc.so.1: cannot open shared object file: No such file or directory
DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading
bash-3.1# g++ dbConnection.obj -o dbConnection -L/usr/lib/SQLAPI/lib -s -lsqlapi -lc -lm -lcrypt -ldl
bash-3.1# export LD_LIBRARY_PATH=/usr/lib/SQLAPI/lib
bash-3.1# ./dbConnection
libiodbc.so: cannot open shared object file: No such file or directory
libiodbc.so.3: cannot open shared object file: No such file or directory
libiodbc.so.2: cannot open shared object file: No such file or directory
libodbc.so: cannot open shared object file: No such file or directory
libodbc.so.1: cannot open shared object file: No such file or directory
DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading
You know, I think the SQLServer Driver is not included in the SQLAPI++. So, I think I need to install the unixODBC driver for SQLServer. You got the same idea?, moreover, if the case is right, I think m not gonna need SQLAPI++ anymore, as I guess, you know, the ODBC manager driver automatically supports SQL APIs.
looking forward to hearing from you.
Saman

New Topic/Question
This topic is locked



MultiQuote




|