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

Getting query results as strings (1 reply)

$
0
0
For a general SQL query, I want to return a map of columns and values converted to strings. However, while cout prints out the value of row[index], I cannot find a way to make sure it is a string rather than some other type. Code like the following fails because I can't convert that row element to a string. How do I go about this?
while ((row = res.fetchOne())) {
for (unsigned index = 0; index < res.getColumnCount(); index++) {
cout << columns[index].getColumnName() << ": "
<< row[index] << endl;
string s1 = columns[index].getColumnName();
string s2 = string(row[index]); //THIS FAILS
stpRow->insert({ s1, s2 }); //add to current map
}

Viewing all articles
Browse latest Browse all 527

Trending Articles



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