开发者

Editing current data in a data table

I am using following data to add new data to my table

Me.TblResultTableAdapter.Fill(Me.DbResultDataSet.tblResult)

Dim drNewRowEditSummary As DataRow
drNewRowEditSummary = DbResultDataSet.tblResult.NewRow
drNewRowEditSummary.Item(1) = "Test"
DbResultDataSet.tblResult.Rows.Add(drNewRowEditSummary)
TblResultTableAdapter.Update(DbResultDataSet.t开发者_开发知识库blResult)

How can I edit my data using similar method as above? Thanks Furqan


DataRowCollection has a Find-Method that returns the DataRow with the given primary key(s). So you should define a pk column, then you get the row with:

Dim drResult As DataRow = DbResultDataSet.tblResult.Rows.Find(1) 'if your pk is 1'
drResult.Item(1) = "Test2"
TblResultTableAdapter.Update(DbResultDataSet.tblResult)

Btw, the same way if you want to delete this row: drResult.Delete()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜