删除数据库中的记录(VB.NET)

时间:2014-11-19 06:53:56

标签: vb.net visual-studio-2010

我正在尝试删除在文本框中输入的人的记录。这是我的代码,我不知道接下来该做什么,因为我的代码无效。

    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 个答案:

答案 0 :(得分:1)

您需要向Command对象添加一个包含@lookup值的参数。

AcademicAssessmentCommand.Parameters.AddWithValue("@lookup", lookup);