用VS2010使用C++写MySQL程序,使用mysql_real_query总弹错误提示!
我之前用VC6.0编写使用MySQL的程序,没有出问题,一样的代码,复制到VS2010就出错,请有经验的人指点。
CString strExecuteSQL, strTableName, strDataTime;
//strTableName, strDataTime, pCollectData就不多说了
strExecuteSQL.Format(_T("insert into %s values('%s', '%.1f', '%.1f', '%.1f', '%.1f', '%.1f')"),
strTableName, strDataTime, pCollectData->dAValue, pCollectData->dBValue, pCollectData->dCValue, pCollectData->dDValue, pCollectData->dEValue);
if ( mysql_real_query(&m_mysql, (char*)(LPCTSTR)strExecuteSQL, (UINT)strExecuteSQL.GetLength()) != 0)
{
const char* pCh = mysql_error(&m_mysql);
CString strTemp;
strTemp = pCh;
AfxMessageBox(strTemp);
return;
}
执行mysql_real_query这句话时候总出错,弹错误提示“You have an error in your SQL Syntax; Check the manual that corresponds to your MySQL Server version for the right syntax to use near 'i' at line 1”。可是我检查SQL语法没有错,无奈……