Solved

Trying to update record with ATL consumer template

Posted on 2000-02-26
5
436 Views
Last Modified: 2013-12-03
I am trying to update a record in an Access database via the standard ATL consumer template classes (namely CTable).

I can read from the database fine, but when I try to update the record, it fails.  Here is some code:

CTable<CAccessor<CUserAccessor> > user;
 
CDBPropSet ps(DBPROPSET_ROWSET);

ps.AddProperty(DBPROP_IRowsetChange, true);
ps.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE);
ps.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("registrar"));
ps.AddProperty(DBPROP_IRowsetUpdate, true);

if (SUCCEEDED(user.Open(m_Session, _T("Users"), &ps)))
{
}

The above line fails with: DB_S_ERRORSOCCURRED

The session is opened succesfully and I can read records from hit (with CCommand).

The only thing I can think of is that the database is read-only, but it is not.


0
Comment
Question by:webview
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:paulburns
ID: 2563384
One problem you've got is in including DBPROP_INIT_DATASOURCE in the property set. This property can only be used with the DBPROPSET_DBINIT group, you are trying to add it to a DBPROPSET_ROWSET group.

You should move this property out of here and into the group used when opening the data source.
0
 
LVL 1

Expert Comment

by:yosit
ID: 2564177
I've seen a problem where u try to add a new record but get the error u mentioned..
to correct this set every field status to ok ...( thru the constant)
before commiting the changes...


yosi
0
 

Author Comment

by:webview
ID: 2564947
I found the problem, I needed to remove this line:

ps.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("registrar"));

The database was already opened via the m_Session parameter
0
 
LVL 2

Accepted Solution

by:
paulburns earned 50 total points
ID: 2566679
great! so my solution worked.
0
 

Author Comment

by:webview
ID: 2567023
Yes, thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

13 Experts available now in Live!

Get 1:1 Help Now