Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems with Insert Command in OLEDB.

Posted on 2000-03-19
3
Medium Priority
?
221 Views
Last Modified: 2013-11-20
I am learning OLEDB. I use the MS JET as my engine. I can do SetData to edit values. This work both with or without delayed mode.
But when I try to practise Insert. I found that it works with DIRECT insert but not in Delayed change (i.e. Insert then Upodate).
e.g.
I set Update property to false (or not setting the property )
I set up some data for the row insertion
I use table.Insert(0), it worked!

but when I
set Update property to true
***
everything else the same.
***
then I use
table.Insert(0), there is no error
table.Update(0). there is an error of hr = 0x80040eda
(that is 'Error has occured', I am not able to decipher the actual error! Including using CError for m_spRowset and IID_RowsetUpdate, using the example in DBViewer.cpp)

Can anybody tell me why this happens, and how do I correct it?
 
0
Comment
Question by:hshliang
[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
3 Comments
 
LVL 2

Accepted Solution

by:
paulburns earned 400 total points
ID: 2634250
try this...

table.Insert(0, true);

....this will fetch the row handle of the new row; the way you are calling Insert does not fetch the row handle, this is why Update() is failing.
0
 

Author Comment

by:hshliang
ID: 2634339
I tried it out, yes it works as you said. Thank you, you make it look so easy, unfortunately it took me hours and still not able to figure out the problem.
0
 
LVL 2

Expert Comment

by:paulburns
ID: 2634382
Dont worry, i think a lot of people have got caught by this too. Why Microsoft decided the default value for the second parameter to Insert() should be 'false' i have no idea!


PS: You might want to look at using AtlTraceErrorRecords() for debugging, its easier to use and you dont have to worry about interface pointer's and GUID's. Use it like this...

HRESULT hr;
hr = m_pSet->GetData(1);
if (FAILED(hr))
{
   AtlTraceErrorRecords(hr);
}


Anyway, thats just for your info. Good luck!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

730 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