Update record in ms access with windows form in VS 2005

irfi

Member
Joined
Sep 24, 2009
Messages
16
Programming Experience
1-3
Hi everyone,
With the following code i am able to update record in the first row. Can some tell me what i have to replace in this code to update a record for a selected row. I have a field "Sr_No" with primary key.
Thanx
irfi

Dim dt As DataTable = ds.Tables("customer")
With dt
.Rows(0)("customer_name") = TextBox1.Text
.Rows(0)("Address") = Text2.Text
.Rows(0)("STATUS") = CheckBox1.CheckState
End With
da.Update(ds, "customer")

MsgBox("Record successfully saved...", MsgBoxStyle.Information)
 
Look at the DataTable.Select method in the help file, it will show how to select the row(s) you are looking for. The select method could return multiple rows depending on your filter. If your using a Typed Dataset you can use the datatable.FindBy"PrimaryIdField" which will return only the one matching row to work with.
 

Latest posts

Back
Top