更新语句不更新数据库记录

时间:2019-04-16 07:05:17

标签: sql asp.net vb.net

SQL更新语句在运行应用程序时不会更新数据库中的记录,但是如果我在SQL Server Management Studio中运行相同的更新语句,它将更新



        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("XXX").ToString())


        Dim command As New SqlCommand("Update EmployeeMedicalTest SET [Date tested] = @DateTested, [Next Due date] = @NextDueDate, ECG = @ECG,  Lungfunction = @Lungfunction,   [Hearing Test] = @HearingTest,  [Eye Test] = @EyeTest,  [Other Problems] = @OtherProblems, Notes = @Notes WHERE Code = @code", conn)

        command.Parameters.AddWithValue("@DateTested", txtDateTested.Text)
        command.Parameters.AddWithValue("@NextDueDate", txtNextDueDate.Text)
        command.Parameters.AddWithValue("@ECG", txtECG.Text)
        command.Parameters.AddWithValue("@Lungfunction", txtLungFunction.Text)
        command.Parameters.AddWithValue("@HearingTest", txtHearingTest.Text)
        command.Parameters.AddWithValue("@EyeTest", txtEyeTest.Text)
        command.Parameters.AddWithValue("@OtherProblems", txtOtherProblems.Text)
        command.Parameters.AddWithValue("@Notes", txtNotes.Text)
        command.Parameters.AddWithValue("@code", txtClockNo.Text)

        conn.Open()
        command.ExecuteNonQuery()
        lblSaveNotify.Visible = True


        conn.Close()

0 个答案:

没有答案