ADO对象读取SQL2008Image数据
我写了一个函数读取数据库中的图像数据,下面是我照着网上的一段代码写的。但是报错说ChunkSize没有定义。我不知道应该给图像的缓存数组定义多大。有人能帮帮我吗?
CFile f;
CString cs = "F:\\学习\\面向对象程序设计作业\\第九章大作业\\test\\jskb_icon(22).bmp";
f.Open(cs,CFile::modeWrite|CFile::modeCreate);
long IPhotoSize = m_pRecordset->Fields->Item["头像"]->ActualSize;
long llsRead = 0;
_variant_t varChunk;
BYTE buf[ChunkSize];
while(IPhotoSize>0)
{
llsRead = IPhotoSize>=ChunkSize?ChunkSize:IPhotoSize;
varChunk = m_pRecordset->Fields->Item["头像"]->GetChunk(llsRead);
for(long index =0;index<llsRead;index++);
::SafeArrayGetElement(varChunk.parray,&index,buf+index);
f.Write(buf,llsRead);
IPhotoSize -= llsRead;
}
f.Close();
[解决办法]
按字节算,图片有多大字节,ChunkSize比图片大点就行。