It seems there is something wrong with this as the record is still in the database. It can be found, but delete doesn't work. What's wrong?
Dim newDataSet As New DataSet
Dim dt As DataTable
Dim dr As DataRow
Dim isfound As Boolean = False
Dim ans As String = Nothing
sqlAdapter.SelectCommand = New SqlCommand("select * from tempdb..Employees", sqlCon)
sqlAdapter.Fill(newDataSet, "FindTable") ' add the table now from adapter tie-up, with a name FindTable
dt = newDataSet.Tables("FindTable") 'assign the dataset table to dt object
For Each dr In dt.Rows
If dr.Item("CtContactId") = CInt(TextBox5.Text) Then
isfound = True
MsgBox(dr.Item("FamilyName"))
dr.Delete()
dt.AcceptChanges()
sqlAdapter.Update(dt)
Exit For
End If
Next
If Not isfound Then
MsgBox("Not Found!")
End If
Dim newDataSet As New DataSet
Dim dt As DataTable
Dim dr As DataRow
Dim isfound As Boolean = False
Dim ans As String = Nothing
sqlAdapter.SelectCommand = New SqlCommand("select * from tempdb..Employees", sqlCon)
sqlAdapter.Fill(newDataSet, "FindTable") ' add the table now from adapter tie-up, with a name FindTable
dt = newDataSet.Tables("FindTable") 'assign the dataset table to dt object
For Each dr In dt.Rows
If dr.Item("CtContactId") = CInt(TextBox5.Text) Then
isfound = True
MsgBox(dr.Item("FamilyName"))
dr.Delete()
dt.AcceptChanges()
sqlAdapter.Update(dt)
Exit For
End If
Next
If Not isfound Then
MsgBox("Not Found!")
End If