Unable to delete data from database in vb.net using SQL Server.
Here is my code for deletion, can you tell me where I have gone wrong?
Name of the table is OneToOne:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
cn.Open()
With cmd
.Connection = cn
.CommandText = " DELETE * FROM OneToOne WHERE SrNo = " & DataGridView1.SelectedRows(0).Cells(0).Value
i = cmd.ExecuteNonQuery
End With
If (i > 0) Then
MsgBox("Conversation Deleted")
End If
cn.Close()
showdata()
End Sub
*, it is not needed in a DELETE query, though I'm not sure that's the sole cause of the problem.