I tried to connect a C++ program in codeblocks IDE to Oracle database.
For that, I downloaded an API named SQLAPI. I took a given example in that API folder
and compiled and linked the appropriate files.
The code is :
#include <stdio.h> // for printf
#include <SQLAPI.h> // main SQLAPI++ header
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(
"XE", // database name
"system", // user name
"system", // password
SA_Oracle_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;
}
But when I run this program, I get following message :
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."
Why this message is coming?