Update after find record

jdy0803

Well-known member
Joined
Sep 9, 2012
Messages
73
Location
Santa Clarita
Programming Experience
10+
In case of VB6.0's ADO, I can update record after find record like this.

rs.Find("patient_id = 2")
rs("NOTES") = "AAAAA"
rs.Update()

But I don't know how to do in VB.NET.
I can find recording using DataView like this.

Sql = "SELECT * FROM patient"
adapter = New OleDbDataAdapter(Sql, cn)
commandBuilder = New OleDbCommandBuilder(adapter)
ds = New DataSet()
adapter.Fill(ds, "patient")
dv = New DataView(ds.Tables("patient"))
dv.Sort = "patient_id"
Dim index As Integer = dv.Find(2)


But, how to update the "first_name" field of the patient table?
I tried like this.
dv(index)("first_name") = "Thomas"
But data does'n be updated.
Can anybody give me advice?
 
When you call Fill on a data adapter it copies the result set of your query from the database into your DataTable. Any modifications you make to the data in your app are made to the copy in the DataTable only. When you call Update on the data adapter, it saves the changes in the DataTable back to the database.
 
Use Datareader for that, all you have to do is to read and update after one cycle of reading. :smile:
 
Back
Top