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

result->getString() no longer works with datetime data types (no replies)

$
0
0
I recently upgraded to C++ Connector 1.1.0 from 1.0.5.

My code mostly still works, except I needed to change some std::string variables into the new sql::SQLString data type.

One table I am retrieving data from has a datetime type.

In 1.0.5 I used to retrieve this data as a std::string, then convert it locally to a time_t struct.

In 1.1.0 this idea no longer works, since using a getString() with the datetime field no longer appears to work (I either get an Access Violation Exception or Bad Pointer). Here is a code snippet summary

std::string sQuery = "select * from my_table";
sql::ResultSet *res;
sql::Statement *stmt;
stmt = m_con->createStatement();
const sql::SQLString & sQueryString(sQuery.c_str());
res = stmt->executeQuery(sQueryString)

// this works in 1.0.5. In 1.1.0 it throws a memory Access exception
std::string my_date = res->getString("date_field")

// these calls both return a Bad Pointer in 1.1.0. No exception thrown, but impossible to access data.
const sql::SQLString & my_date1(res->getString("date_field"));
const sql::SQLString my_date2(res->getString("date_field"));

// this works in 1.0.5 and 1.1.0
const sql::SQLString & my_field = res->getString("actual_string_field")

// these calls all return '2010' in 1.1.0
int iDate = res->getInt("date_field")
long lDate = res->getLong("date_field")
double dDate = res->getDouble("date_field")

Note that this issue seems to only appear with datetime data. For actual string data (or other types such as int, no issues)

I am using VS2010. I get the above result for both Debug and Release builds.

Nick

Viewing all articles
Browse latest Browse all 527

Trending Articles



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