Solved

Problems with Insert Command in OLEDB.

Posted on 2000-03-19
3
215 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

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 106
format the code in java 6 86
FizzBuzz challenge 9 76
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 242
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

914 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

15 Experts available now in Live!

Get 1:1 Help Now