如何在数据库中存入位图?
我的DBMS 为SQL SERVER 7.0.应用程序用VC6.0开发。
位图字段类型为Binary,用ClassWizard 自动生成了CMyRecordSet 类,将位图字段
映射为CLongBinary 类型的成员变量(m_image)。
我试图向表中插入一字段。以下为我的代码:
m_pSet ->AddNew();
m_pSet ->SetFieldDirty(NULL);
if ( m_pSet ->m_image.m_hData) GlobalFree ( m_pSet ->m_image.m_hData);
m_pSet ->m_image.m_hData = GlobalAlloc(GMEM_FIXED,iSize);
m_pSet ->m_image.m_dwDataLength = iSize;
void * pGlobal = GlobalLock(m_pSet ->m_image.m_hData);
...... //fill the imagedata into the global buffer
GlobalUnlock(m_pSet ->m_image.m_hData);
...... // fill the other field.
m_pSet ->Update();
但是执行完后查看数据库记录,该图象字段并没有写入,如果让图象字段禁止为NULL的话,执行到这儿就回弹出错误框,指示图象字段不能为NULL。
请问各位我如何解决这个问题?