这样的例子,在网上有很多。主要代码:
CFile m_File;
m_File.Open(szFileName, CFile::modeRead);
DWORD dwLen = m_File.GetLength() + 1;
char * szBuffer = new char[dwLen];
m_File.ReadHuge(szBuffer, dwLen);
m_File.Close();
SAFEARRAY* m_pSafe;
SAFEARRAYBOUND m_Band;
m_Band.cElements = dwLen;
m_Band.lBound = 0;
m_pSafe = SafeArrayCreate(VT_VI1, 1, &m_Band);
for(long i=0; i<dwLen; i++)
{
SafeArrayPutElement(m_pSafe, &i, szBuffer++);
}
//将数据保存到数据库
VARIANT m_BitData;
m_BitData.vt = VT_ARRAY | VT_UI1;
m_BitData.parray = m_pSafe;
ADORecord->GetFields()->GetItem("字段名")->AppentChunk(m_BitData);