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
}
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
}