DataAdapter not updating

R

Rich

Hello,

On a form I have 3 textboxes, txt0, txt1, txt2 which
contain all integers. I have also placed a connection
component (conn), dataadapter component (da1) and dataset
component (ds1) from the toolbox on to the form. I
established a connection to an Access mdb file and can
display data correctly on the form in the textboxes. The
textboxes are bound to columns in the dataset. So the
only code I have to populate the form is on the Form_Load
event

ds1.Clear
da1.Fill(ds1, "tbl1")

This works fine. But if I change/modify the data in one
of the textboxes and execute

da1.Update(ds1, "tbl1")

the data does not get updated in Access. I have tried
populating the parameters for the
da1.UpdateCommand.Parameters collection

da1.UpdateCommand.Parameters("fld1").Value = txt1.text

(while I'm at it, the above line didn't work either -
problem casting text to int - how to do that properly?)
so I did the following:

da1.UpdateCommand.Parameters("fld1").Value = 1234
da1.Update(ds1, "tbl1")

but this did not update tbl1 either. How do I make the
dataAdapter work to update?

Thanks,
Rich
 
C

Cor

Hi Rich,

Can be anything but this is the first thing to try before your dataadapte
update
(If it is a databinded textbox)

BindingContext(ds1t, "tbl1").EndCurrentEdit()
da1.Update(ds1, "tbl1")

I hope this helps,

Cor
 
R

Rich

Thanks. I am guessing that would go like this?
....
BindingContext(ds1, "tbl1").EndCurrentEdit()
da1.Update(ds1, "tbl1")
End Sub

I will give that a try.

Thanks again,
Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top