Solved

Problems with Insert Command in OLEDB.

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 125
iSeries FTP Exit Program 8 113
countEvens challenge 2 57
matchUp  challenge 6 48
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

14 Experts available now in Live!

Get 1:1 Help Now