Solved

Trying to update record with ATL consumer template

Posted on 2000-02-26
5
441 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

947 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

19 Experts available now in Live!

Get 1:1 Help Now