我被困在这个问题上,似乎无法解决它,我的代码在下面运行,如果有一条记录更新,则 checkinsert 返回 1,如果没有,则返回 0,问题出在 Access 中,表列未更新。
我找不到它为什么不起作用,所以我希望一双新的眼睛能发现问题。
如果我在 Access 中运行更新视图,它可以正常工作。
UPDATE tblStudentNameAndScore 
SET tblStudentNameAndScore.QuizCount = QuizCount+1, 
tblStudentNameAndScore.TimeLastQuestionAsked = Now()
WHERE tblStudentNameAndScore.StudentID=[?];
VB.Net
Public Function UpdateStudentScoreIfAnswerCorrect(ByVal studentId As String) As String
            Try
                Dim strAccessConn As String = _appConfigDbConn
                Dim cn As OleDbConnection = New OleDbConnection(strAccessConn)
                cn.Open()
                Dim da As New OleDbCommand("qryUpdateStudentScore", cn)
                da.CommandType = CommandType.StoredProcedure
                'da.Parameters.AddWithValue("@StudentID", studentId)
                da.Parameters.Add("@StudentID", OleDbType.VarChar).Value = studentId
                Dim checkinsert As New Integer
                checkinsert = da.ExecuteNonQuery()
                If checkinsert > 0 Then
                    Return "Success"
                End If
                cn.Close()
                cn.Dispose()
                Return "Fail"
            Catch ex As Exception
                Throw New ApplicationException(ex.InnerException.Message.ToString())
            End Try
        End Function
我正在使用 Access 2010 和 VB.NET Express
谢谢你的帮助