picpath[j]是指针数组,存放图片的路径。
各位看一看问题出哪了 for (int j=0;j<=i;j++)
{
CFile file( picpath[j], CFile::modeRead); int nFileLen = file.GetLength();
if ( nFileLen<= 0 )
{
file.Close();
return;
}
BYTE* theFileContent = new BYTE[ nFileLen];
file.Read( theFileContent, nFileLen);
file.Close();
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate( VT_UI1, 1, rgsabound);
void* theArrayBuffer = NULL;
::SafeArrayAccessData(psa, (void **)&theArrayBuffer);
memcpy( theArrayBuffer, theFileContent, nFileLen);
::SafeArrayUnaccessData(psa);
delete [] theFileContent;
VARIANT varChunk;
varChunk.vt = VT_ARRAY|VT_UI1;
varChunk.parray = psa; char s[2];
itoa(j,s,10);
CString s1="SELECT * FROM M_Pic where Id=" ;
CString strSQL = s1+ s; MessageBox(strSQL);
if ( m_pRecordset->GetState() )
m_pRecordset->Close();
m_pRecordset->Open( (_variant_t)strSQL,variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset->Fields->GetItem(_variant_t("Pic"))->Value=varChunk;
m_pRecordset->Update();
SafeArrayDestroy( psa);
free(picpath[j]);
}
各位看一看问题出哪了 for (int j=0;j<=i;j++)
{
CFile file( picpath[j], CFile::modeRead); int nFileLen = file.GetLength();
if ( nFileLen<= 0 )
{
file.Close();
return;
}
BYTE* theFileContent = new BYTE[ nFileLen];
file.Read( theFileContent, nFileLen);
file.Close();
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nFileLen;
psa = SafeArrayCreate( VT_UI1, 1, rgsabound);
void* theArrayBuffer = NULL;
::SafeArrayAccessData(psa, (void **)&theArrayBuffer);
memcpy( theArrayBuffer, theFileContent, nFileLen);
::SafeArrayUnaccessData(psa);
delete [] theFileContent;
VARIANT varChunk;
varChunk.vt = VT_ARRAY|VT_UI1;
varChunk.parray = psa; char s[2];
itoa(j,s,10);
CString s1="SELECT * FROM M_Pic where Id=" ;
CString strSQL = s1+ s; MessageBox(strSQL);
if ( m_pRecordset->GetState() )
m_pRecordset->Close();
m_pRecordset->Open( (_variant_t)strSQL,variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset->Fields->GetItem(_variant_t("Pic"))->Value=varChunk;
m_pRecordset->Update();
SafeArrayDestroy( psa);
free(picpath[j]);
}
解决方案 »
- 自定义的CStaic控件(就是说从CStatic继承)帖在dialog上面,它自己的OnCtlColor不会响应,dialg的OnCtlColor也没针对消息过来
- 只有在OnPrepareDC中才可以设定映射模式,OnPrepareDC由OnDraw()调用,那么dialog程序就不用设置坐标映射模式了?
- access网络访问
- 有对简谱软件感兴趣的公司吗?
- 如何能修改VS2005中代码的字体?
- 如何改变对话框程序中对话框的背景色?
- 如何用ADO实现超大型表的查询???
- 请教高手!如何分别设置List的右键单击事件和右键单击item事件
- >>>>>>>>>>>>>>>>>>机器上的一个TCP|UDP端口被打开,怎么关闭它呢?
- 简单问题松10分
- 视频连接,调用CoCreateInstance,Win7报故障,xp正常
- 关于网络编程中多线程都调一个函数来接收数据,线程间的数据不受干扰呢?
你用的m_pRecordset不知道是什么类你把值赋给了value然后update就能存到数据库里了?
另外不知道是不是我见识少,见到的都是存储路径的,头一次见到需要把图片以二进制方式存储在数据库里。
你没有打开文件就不要调这个
是支持的,把for循环去掉单个储存是可以的,但加上循环就出错了。