Update DataSet or DataTable

R

ruca

Hi,

Can I update a DataSet or a DataTable using something like object.Update()
???

I was looking for something and I find out this functions, but I don't know
for real what they do.
AcceptChanges()
BeginEdit()
EndEdit()

I try to use them like this, to change the value of a field in first row:
ds.Tables("P").Rows(0).AcceptChanges()
ds.Tables("P").Rows(0).BeginEdit()
ds.Tables("P").Rows(0).Item("Num") = 9999
ds.Tables("P").Rows(0).EndEdit()


But it doesn't work.
Can I do something like this???
 
L

Lars Netzel

If you are using a DataAdapter to handle the DataSet you can use:

DataAdapter.Update(Dataset)

/Lars
 
C

Cor Ligthert

Hi Ruca,
Can I update a DataSet or a DataTable using something like object.Update()

This code you wrote you can use,
ds.Tables("P").Rows(0).Item("Num") = 9999

I think that the rest you wrore is useles for you,

And than you have normaly in the simple way to make the following code(which
is all typed in this message without checking)

dim connection as new xxx connection(connectionstring)
dim da as new xxxdataadapter(selectstring, connection)
dim cmb as new commandbuilder(da)
if ds.haschanges
da.update(ds)
end if

and the last part in a try catch end try block.
Normaly it is not needed to open and close the connection, that does the
dataadapter himself.
(he closes only a from himself opened connection)

I hope this helps something

Cor
 

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

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top