Solved

Problems with Insert Command in OLEDB.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 76
sumDigits challenge 9 179
sum67 challenge 35 130
How do I get Window Title of all opened process? 4 61
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Suggested Courses

751 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