Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Dim conn As MySqlConnection
conn = New MySqlConnection()
Dim test As String
Dim commandSQL As MySqlCommand
If MsgBox("OK to delete parent: " + DataGridView1.CurrentRow.Cells(0).Value + "?", MsgBoxStyle.OkCancel, "Delete Progress") = MsgBoxResult.Ok Then
'delete it from the dataset
test = String.Concat(String.Concat("DELETE FROM PARENT WHERE NAME ='" + DataGridView1.CurrentRow.Cells(1).Value + "'"))
conn.ConnectionString = "server=localhost;" _
& "user id=root;" _
& "password=123456;" _
& "database=mydatabase"
Try
conn.Open()
commandSQL = conn.CreateCommand()
commandSQL.CommandText = test
If (commandSQL.ExecuteNonQuery() > 1) Then
MessageBox.Show("Data Delete Successfully")
End If
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try
Else
DataGridView1.Refresh()
End If
End Sub
hi..i have some problems with this code above..this code doesnt delete the selected row and in the sql database..pls help me with this code and much appreciate it..and also this code cant delete selected row..pls advice tq..:)