Solved

Trying to update record with ATL consumer template

Posted on 2000-02-26
5
457 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

622 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