Can you please paste your code here? so that we can help..
Private Sub Deletebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click con.Open() Dim sqlDeleteItem As String Dim a As Integer Dim db As SqlCommand Dim answer As Integer a = DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value answer = MsgBox("Do you want to delete the User?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "") If answer = vbYes Then sqlDeleteItem = "delete from Users where User_id = " & a & "" db = New SqlCommand(sqlDeleteItem, con) db.ExecuteNonQuery() MsgBox("User Deleted!", MsgBoxStyle.Information, "") ds.Clear() da = New SqlDataAdapter("Select * from Users", con) da.Fill(ds, "Users") DataGridView1.DataSource = ds.Tables("Users").DefaultView Else End If con.Close() End Sub
I am not familiar with DataGrid with vb, and i use ListView a lot of times.
maybe you can adopt this code and can give you an idea how to delete selected record.
sql "DELETE * FROM tblpwd where modusername = '" & lstUsers.SelectedItem.Text & "' "