Click to See Complete Forum and Search --> : The Steps to add new record using DAO


IcWang
July 2nd, 1999, 01:18 PM
Hi:

I want to add new record in CDaoRecordset and the code below:

CString strSQL="SELECT * FROM tablename";
m_database.Open("c:\\My Documents\\db1.mdb",TRUE,TRUE);
m_addSet = new CDaoRecordset(&m_database);
m_addSet->Open(dbOpenDynaset,strSQL,0);
m_addSet->AddNew(); // problem encounter here !!
m_addSet->SetFieldDirty( NULL );
m_addSet->SetFieldValue("...",LPCTSTR("..");
m_addSet->SetFieldValue("...",LPCTSTR(".."));
m_addSet->SetFieldValue("...",LPCTSTR(".."));
m_addSet->SetFieldValue("...",LPCTSTR(".."));
m_addSet->Update();
m_addSet->Close();

and when executing the statement m_addSet->AddNew();
tracing into "daocore.h" line 3987, the error occurred in statement
ASSERT(fx.m_nFieldFound != 0);
and I cant figure out where I went wrong and I think I didn't take
the right steps to add new record,
can you show me the right one? thanx for your comments!!