MySQL Forums
Forum List  »  Connector/C++

Runs sql-scripts with mysql++
Posted by: Franz Engel
Date: February 16, 2012 09:05AM

Hello,

I want to create a c++ program to start different sql-scripts. But I get always the same failure, so I tried it like this:
sqlConnection->query("SET @tableName:='car.Position';");

if (mysqlpp::StoreQueryResult res = sqlConnection->query("SELECT COUNT(*) FROM @tableName;").store())
{
for (size_t i = 0; i < res.num_rows(); ++i)
{
cout << res[0] << endl;;
}
}
else
{
cerr << "DB connection failed: " << sqlConnection->error() << endl;
return false;
}

The background is that sometimes I working with the workbench and sometimes I want to worke with my one gui where I have buttons that runs diffent scripts (for a higher consistency I want to work with the same scripts).
But the "Set @tableName"-statement makes trouble. I think that mysql++ can't deal with this statment. Does anybody knows a methode to solve my problem?

Thanks in advance,
Franz

Options: ReplyQuote


Subject
Views
Written By
Posted
Runs sql-scripts with mysql++
2509
February 16, 2012 09:05AM


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.