update problem in dataset....

  • Thread starter Thread starter Raphaël Désalbres
  • Start date Start date
R

Raphaël Désalbres

Hello,

I've the following problem:

A simple table (Users) with 2 fields, UserID (Primary key) and UserName

The code:

dim cnn as new oledbconnection
cnn.connectionstring="Provider=Microsoft.JET.OLEDB.4.0;Data Source=" &
server.mappath("bd1.mdb")
cnn.open
dim da as new oledbdataadapter("SELECT * FROM Users",cnn)
dim ds as new dataset()
dim dr as datarow
da.fill(ds,"Users")
dr =ds.Tables("Users").Rows(3)
dr("UserName") = "Raphaël Désalbres"
da.update(ds,"Users")
cnn.close

Produces the following error:
Update requires a valid UpdateCommand when passed DataRow collection with
modified rows.
How can I update the table using Dataset...

Thanks,

Raphaël...
 
Hi Raphael,

Try for this simple kind of updates this, when they commands become more
complex you can see how to build the update, insert and delete commands
yourself
dim cnn as new oledbconnection
cnn.connectionstring="Provider=Microsoft.JET.OLEDB.4.0;Data Source=" &
server.mappath("bd1.mdb")
cnn.open
dim da as new oledbdataadapter("SELECT * FROM Users",cnn)
dim ds as new dataset()
dim dr as datarow
da.fill(ds,"Users")
dr =ds.Tables("Users").Rows(3)
dr("UserName") = "Raphaël Désalbres"
cmb as new oledbcommandbuilder(da)
da.update(ds,"Users")
cnn.close

I hope this helps?

Cor
 
Thanks very much!!!

I needed exactly this!!!

Best regards,

Raphaël........
 
Back
Top