我遇到了参数化SQL Lite查询的一些问题。我似乎无法让SQL Lite参数接受String值
Using cmd As SQLiteCommand = pConn.CreateCommand()
If tblLang = "en" Then
cmd.CommandText = "UPDATE [AT_Strings] SET [Data] = @tblData + 1 WHERE [RecordID] = @ID AND [language] = @tblLang1"
Dim tblData As New SQLiteParameter("@tblData")
Dim ID As New SQLiteParameter("@ID")
Dim tblLang1 As New SQLiteParameter("@tblLang1")
cmd.Parameters.Add(dataText)
cmd.Parameters.Add(ID)
cmd.Parameters.Add(tblLang)
Else
cmd.CommandText = "UPDATE [AT_Strings] SET [Data] = @dataText + 1 WHERE [RecordID] = @ID AND [language] = @tblLang1"
Dim tblData As New SQLiteParameter("@dataText")
Dim ID As New SQLiteParameter("@ID")
Dim tblLang1 As New SQLiteParameter("@tblLang1")
cmd.Parameters.Add(dataText)
cmd.Parameters.Add(ID)
cmd.Parameters.Add(tblLang)
End If
cmd.ExecuteNonQuery()
End Using
错误如下....
Unable to cast object of type 'System.String' to type 'System.Data.SQLite.SQLiteParameter'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Data.SQLite.SQLiteParameter'.
Source Error:
Line 283: Dim ID As New SQLiteParameter("@ID")
Line 284: Dim tblLang1 As New SQLiteParameter("@tblLang1")
ERROR on Line 285...
Line 285: cmd.Parameters.Add(dataText)