mediumblob存图像数据的问题
一点也不酷 2015-06-14 07:25:48 用的opencv的库采集的图像,存到MYSQL里面的一个mediumblob里面,代码执行有时候成功有时候失败,失败的时候mysql错误显示语法错误,搞了半天不知道什么原因,盼大神帮忙分析下
代码如下
IplImage* m_Frame;
m_Frame=cvQueryFrame(capture);
long nSize = m_Frame->imageSize;
char* pBuf = m_Frame->imageData;
char* pToDes = new char[nSize*2+1];
long lDestSize = mysql_real_escape_string(theApp.mysql.GetMysql(), pToDes, pBuf, nSize);
char* cQuery = new char[nSize*2+100];
int sql_len = sprintf(cQuery,"update staffphoto set photo = \'%s\' where code = 1",pToDes);
string strQuery = cQuery;
if( theApp.mysql.MysqlEx(strQuery) )
{
string strError = theApp.mysql.OutErrors();
GetDlgItem(IDC_STAFFREG_MES_EDIT)->SetWindowText(_T("读取數據失敗!"));
delete []pToDes;
delete []cQuery;
return;
}
theApp.mysql.FreeRecord();
delete []pToDes;
delete []cQuery;