Link to home
Start Free TrialLog in
Avatar of RonaldBiemans
RonaldBiemans

asked on

deleting just created record using ado

I have a form with an 2 ADO datacontrols
2 buttons  (add and delete)
a couple of textboxes bound to the datacontrol and a datacombobox using both datacontrols.

problem: I add a new record (.addnew), fill a couple of text boxes and than
try to delete the record (.delete)
I get an error message saying
"provider called a method from IRowsetNotify in the consumer and the method has not yet returned"

I can remedy this problem by using
.moveprevious and .movenext before deleting but that can't be the proper way to do this.

(I think it has something to do with the datacombo I'm using because I don't get the error when I don't use it (duh))
Avatar of daeus
daeus

Try calling the update method first:

rs.addnew

'make changes to the data

rs.update

rs.delete


Or, you can call the cancelUpdate method:

rs.addnew

'make changes

rs.cancelUpdate


This should discard the newly created record.
What about just executing a SQL statement which deletes the record?
Avatar of RonaldBiemans

ASKER

Evertd, sorry for rejecting your answer
but it is customary in EE to give your answer as a comment( even if you are sure it is the right answer) this allows for a much broader discussion.

and it allows the one who asked the question (me) to decide which answer solved my problem.

Hmm, we had the same type of problem once.

Apparently, when you have two ADODB.Recordsets, there's always one behind.  

We searched on Technet and found that the problem is "by design".  The solution is to open both recordsets in the same connection.

When you do that, changes are 'seen' by you're second recordset immediatly.  I think you won't get the problem then.

Give it a try.
By the way, I don't like EE's way of answering questions nowadays.

I'm getting bored of reading questions I want to answer and find 10 people with a correct answer before me.  Answered questions should be ruled out.

(But I don't think the rejected answer, was worth that name)
ASKER CERTIFIED SOLUTION
Avatar of vindevogel
vindevogel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was much simpler than that
I just had to put

adodc1.refresh (not update that didn't work) before the
adodc1.delete
and that did the trick

I will award the points to vindevogel
because his suggestion worked as well.


Comment accepted as answer