Hi,
I have the following code which I am using to connect a windows console application to MySQL (using the SQLAPI++ connector).
#include <iostream>
#include <stdio.h>
#include <sqlapi.h>
using namespace std;
int main(int argc, char* argv[])
{
SAConnection con; //create connection object
try
{
con.Connect("test","root","catssss1",SA_MySQL_Client);
printf("We are connected!\n");
//con.Disconnect();
//printf("We are disconnected!\n");
}
catch(SAException &x)
{
try
{
con.Rollback();
}
catch(SAException &)
{
}
printf("%s\n", (const char*)x.ErrText());
}
SACommand cmd(& con);
cmd.setCommandText("INSERT INTO model.buildingstatus (idBuildingStatus, item, status) VALUES(:1,:2,:3)");
cmd.Param(1).setAsLong() = 3;
cmd.Param(2).setAsString() = 4;
cmd.Param(3).setAsLong() = 5;
cmd.Execute();
cin.get();
return 0;
}
It connects fine however when I try to execute the 'setCommandText' line I get this error:
Unhandled exception at 0x75c69673 in Sql_datatbase_test.exe: Microsoft C++ exception: SAException at memory location 0x001af794.
Would anybody be able to offer me any suggestions why?
I have followed the instructions on:
http://www.sqlapi.com/HowTo/commands.html
Thank you