-3

I have following code to fill my dataset (ASP.Net).

Dim conStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbTest.mdf;Integrated Security=True;User Instance=True"
    Dim sqlQry As String = "SELECT * FROM tblTest"
Dim dAdt As New SqlDataAdapter(sqlQry, conStr)
Dim dSet As New DataSet()

dAdt.Fill(dSet, "tblTest")

Then I am using following to edit my record

Dim dRow As DataRow
    dRow = dSet.Tables("tblTest").Rows(1)
    dRow.BeginEdit()
    dRow.Item("Name") = txtName.Text
    dRow.EndEdit()
    dSet.Tables("tblTest").AcceptChanges()

it does not generate any error but does not edit the record too. Same is happening when I try to delete record using delete command. Please advise. Thanks

franklins
  • 3,710
  • 6
  • 41
  • 56
Furqan Sehgal
  • 4,917
  • 33
  • 108
  • 167

2 Answers2

0

I think you need to call "update" before AcceptChanges.

Something like:

dset.Update();
Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
0

Try adding the BeginEdit() and AcceptChanges() methods, like this:

drRow.BeginEdit()
drRow("Name") = txtName.Text

dsSet.Tables("tblTest").AcceptChanges()
James Johnson
  • 45,496
  • 8
  • 73
  • 110