I am having some issues with a parameterized SQL Lite query. I can’t seem to get the SQL Lite Parameter to accept the String value
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
The error is as follows….
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)
This is how I solved this issue…
Hope this helps someone else!!