update problem in dataset....

  • Thread starter Raphaël Désalbres
  • 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...
 
C

Cor

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
 
R

Raphaël Désalbres

Thanks very much!!!

I needed exactly this!!!

Best regards,

Raphaël........
 

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