Solved

Problems with Insert Command in OLEDB.

Posted on 2000-03-19
3
218 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
paulburns earned 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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