What is the correct syntax to Update a calendar change to the sqlite database? The INSERT code works as expected, but when I try to UPDATE a changed date, I get an error. This is the code I am using:
db.ExecuteSQL ("UPDATE Characters SET Character_Date = '" + DateofBirth.SelectedDate + "' WHERE ID = " + CharacterID_Selected)
the error message is: Undefined operator. Type TextLiteral does not define "Operator_Add" with type DateTime db.ExecuteSQL ("UPDATE Characters SET Character_Date = '" + DateofBirth.SelectedDate + "' WHERE ID = " + CharacterID_Selected)
What do you see on the database?
Can you pull the information from the database? What code do you use to pull the information from the database?
Do you understand what the error message is telling you?
Basically you are using db.ExecuteSQL(string) but you are trying to concatenate string + DateTime + string (assuming CharacterID_Selected is string too) and you can’t do that.
I always use a property to build the SQLite Command String.
Read the code extract below:
If gDB.Connect Then
// Add a TABLE And RowsÂ…
Var SQL_Cmd As String
SQL_Cmd = "CREATE TABLE IF NOT EXISTS Customers(CustomerID INTEGER, " +_
"CustomerName TEXT, ContactName TEXT, Address TEXT, City TEXT, PostalCode TEXT, " +_
"Country TEXT, ID INTEGER NOT NULL, PRIMARY KEY(ID));"
gDB.ExecuteSQL(sql_Cmd)
The code compiles even if the SQLite Command is wrong. To be sure about the SQL_Cmd contents, you can use:
System.DebugLog SQL_Cmd
and you will get the contents of the property as string if you click (while the program runs in the ide) in
Concatenating objects in a SQLite Command String… always results in troubles. As its name imply, the SQLite Command String holds Strings.
Read String to know how to convert whatever kind of variable into String.
Would be surprise me if Aliens would be using sqlite in the 24th century… I understand the risks about the SQL Injections, but I don’t think this is very important in the app I am building which is for story development for a single user. No money laundry dangers here. Also, because I am still at the start of understand how to work with databases I want to understand first the basics of it before adding a layer of something else. Nice blog tough, thanks