Solved

DAO Update() problem

Posted on 1998-01-22
3
249 Views
Last Modified: 2013-11-20
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!!!
0
Comment
Question by:descott
  • 2
3 Comments
 
LVL 2

Expert Comment

by:dhodge
Comment Utility
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.
0
 

Author Comment

by:descott
Comment Utility
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

0
 
LVL 2

Accepted Solution

by:
dhodge earned 50 total points
Comment Utility
Clutching at straws now, but I always find that its a good idea to try and problems out in Access first.  This will rule out any silly errors like the user doesn't have update / add authority on the db.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now