Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

Runs sql-scripts with mysql++ (no replies)

$
0
0
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[i][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

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>