Click to See Complete Forum and Search --> : Q:dll problem


Brett Liu
April 20th, 1999, 03:09 AM
I write a dll by VC++,in this dll I use DAO to operate a access database,which put a longbinary field into a access database. This dll does work in vc++ test program,but when vb program call this dll, a fatal error occured : visual basic program quits abnormally,Who can tell me why ? thanks

Brett Liu
April 20th, 1999, 10:32 AM
Here is the code I used in my dll ,please read it,tell me what is wrong ,thanks

if(!m_rSet_a.IsOpen()) m_rSet_a.Open();
if(!m_rSet_a.Find(AFX_DAO_FIRST,ID)){
m_rSet_a.Close();
CString ID_message;
ID_message="There has no "+ID+" in this Database";
AfxMessageBox(ID_message);
return FALSE;
}

m_rSet_a.Edit();
FILE* f=fopen(pnFileName,"rb");
fseek(f,0,SEEK_END);
unsigned long len=ftell(f);
if(len>GlobalSize(m_rSet_a.m_PIC.m_hData))
m_rSet_a.m_PIC.m_hData=GlobalAlloc(0,len);
char* p=(char*)GlobalLock(m_rSet_a.m_PIC.m_hData);
fseek(f,0,SEEK_SET);
fread(p,1,len,f);
fclose(f);
GlobalUnlock(p);
m_rSet_a.m_PIC.m_dwDataLength=len;
m_rSet_a.SetFieldDirty(&m_rSet_a.m_PIC);
m_rSet_a.SetFieldNull(&m_rSet_a.m_PIC,FALSE);
m_rSet_a.Update();
::GlobalFree(m_rSet_a.m_PIC.m_hData);
m_rSet_a.Close();
return TRUE;