📅  最后修改于: 2022-03-11 15:00:06.544000             🧑  作者: Mango
Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click
Try
connection.Open()
Using command As New SqlCommand("DELETE FROM students WHERE STUDENT_NUMBER = @NUM", connection)
command.Parameters.Add("@NUM", SqlDbType.VarChar).Value = txtRegNumber.Text
command.ExecuteNonQuery()
MessageBox.Show("DATA WAS DELETED sUCCESSFULLY")
End Using
connection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub