1
sql::Driver     *driver;
sql::Connection *dbConn;
sql::Statement  *stmt; 
try{
    driver = get_driver_instance(); 
    dbConn = driver->connect("tcp://172.0.0.1:3306", "user", "password");
    stmt = dbConn->createStatement();
    dbConn->setSchema("zabbix");
    res = stmt->executeQuery("INSERT INTO table(name,surname) VALUES ('123','33333333')");
}catch (sql::SQLException e)    {
    cout << "SQL error. Error message: " << e.what() << endl;
}   

Hello guys, I have the following problem: in this code I am trying to insert data to my table, but when the code arrives to row execute query it's going to catch part (error code: 0) and data has been inserted, and when I am trying to execute code without the try/catch, the program is being blocked.

Error point:

[First <kbd>F5</kbd>] `Unhandled exception at 0x00007FFF7B254008 in ConsoleApplication3.exe: Microsoft C++ exception: sql::SQLException at memory location 0x00000014AFDDF5F0.`


[Second <kbd>F5</kbd>]: `Unhandled exception at 0x00007FFF7BCEA508 (ucrtbase.dll) in ConsoleApplication3.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.`

which is the cause of this problem? how to use correctly insert to table?

1
  • Visual Studio 2017 Commented Jul 5, 2018 at 6:38

1 Answer 1

1

I found the solution to the problem, the problem was the following: i changed executeQuery in executeUpdate and code it does not go anymore in catch part (google translate)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.