MySQL Forums
Forum List  »  Connector/C++

Get Error but query works
Posted by: Thorsten Petersen
Date: October 06, 2009 06:58AM

I wrote a program which is reading all the time data from a table in a loop

  sql::Driver *driver;
  sql::Connection *con;
  sql::Statement *stmt;
  sql::ResultSet *res;

 driver = get_driver_instance();
  con = driver->connect("localhost:3306", "root", "");

  stmt = con->createStatement();

  stmt = con->createStatement();

  sprintf(sql_query, "SELECT * FROM buildquery WHERE zeit<=%d Order by zeit DESC",time(NULL));
	res = stmt->executeQuery(sql_query);

while (res->next()) {

// ...  edit some results -> get sz,sz2,sz3,sz4 (they are correct) ...

sprintf(sql_up_query, "Update villages Set %s=%s+1 Where vid='%s'  ",sz2,sz2,sz);


	sprintf(sql_del_query, "Delete from buildquery Where id=%s  ",sz4);


 }catch (sql::SQLException &e) {
 cout << "# ERR: SQLException in " << __FILE__;
 cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
 cout << "# ERR: " << e.what();
  cout << " (MySQL error code: " << e.getErrorCode();
  cout << ", SQLState: " << e.getSQLState() << " )" << endl;

The querys work and the first updates the table
but after that I get an error :

#ERR: SQLException in .\buildquery.cpp(main) on line 164
#ERR: (MySQL error code: 0, SQLState: 00000

and the program stop reading and editing the table

How can I do it right?

Sorry for my bad english - I´m german ;)

Options: ReplyQuote

Written By
Get Error but query works
October 06, 2009 06:58AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.