Deleting the records in the database (VB.NET)

2019-08-23 06:39发布

I am trying to delete the record of a person entered in the textbox. This is the code I have and I don't know what to do next because my code is not working.

    AcademicAssessmentConnection = New OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\AdvisorAssessmentTool.accdb")

    AcademicAssessmentConnection.Open()

    AcademicAssessmentCommand = New OleDbCommand()
    AcademicAssessmentCommand.Connection = AcademicAssessmentConnection
    AcademicAssessmentCommand.CommandText = "DELETE (*) from Students where StudentID = @lookup"
    AcademicAssessmentCommand.ExecuteNonQuery()
    MsgBox("Successfully Deleted")
    AcademicAssessmentConnection.Close()

1条回答
走好不送
2楼-- · 2019-08-23 06:56

You need to add a parameter to the Command object that contains the value for @lookup.

AcademicAssessmentCommand.Parameters.AddWithValue("@lookup", lookup);
查看更多
登录 后发表回答