Link to home
Start Free TrialLog in
Avatar of descott
descott

asked on

DAO Update() problem

I am trying to use DAO to add a new record with the AddNew()
and Update() functions using DDX.  I get an exception error #
3265 that says "Item not found in this collection".  Database was
created with Access 7.0 for Win95.  Coding in VC++ 4.0.
Please help!!!
Avatar of dhodge
dhodge

You must check that the fields are bound correctly, go into class wizard and re-bind the variables.

Secondly if you are using a non-default sql statement just check to see if the fields you're expecting to modified are present in the sql.
Avatar of descott

ASKER

I tried his suggestions to no avail.  Note that I can read and delete
records without a problem.

Here is my code:

CTestSet::CTestSet(CDaoDatabase* pdb)
      : CDaoRecordset(pdb)
{
      //{{AFX_FIELD_INIT(CTestSet)
      m_Id = 0;
      m_nFields = 1;
      //}}AFX_FIELD_INIT
      m_nDefaultType = dbOpenDynaset;
}

CString CTestSet::GetDefaultDBName()
{
return _T("E:\\projects\\DrScott\\drscott.mdb");
}

CString CTestSet::GetDefaultSQL()
{
      return _T("[Test]");
}

void CTestSet::DoFieldExchange(CDaoFieldExchange* pFX)
{
      //{{AFX_FIELD_MAP(CTestSet)
      pFX->SetFieldType(CDaoFieldExchange::outputColumn);
      DFX_Short(pFX, _T("[Id]"), m_Id);
      //}}AFX_FIELD_MAP
}

CTestSet *Set = new CTestSet(NULL);
Set->Open();
Set->AddNew();
Set->m_Id = 4;
Set->Update();
Set->Close();
delete Set;

The update causes an exception # 3265 "Item not found in this
collection"

Thanx alot in advance
Dave Scott
de-scott@mindspring.com

ASKER CERTIFIED SOLUTION
Avatar of dhodge
dhodge

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial