Unable to insert records into SQLite database
Posted: Sun Jan 05, 2025 3:45 pm
I'm sure this is because I'm missing some basic aspect of SQLite, I just started really learning how to use it a couple days ago, but this has me stumped. I've gotten it down to this minimal example:
When I run this, the table is created, but the record never gets inserted, even though DatabaseUpdate() returns 1. What am I doing wrong?
Thanks!
Code: Select all
EnableExplicit
UseSQLiteDatabase()
OpenFile(0, "test.db")
CloseFile(0)
OpenDatabase(0, "test.db", "", "")
DatabaseUpdate(0, "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)")
SetDatabaseString(0, 0, "John")
SetDatabaseString(0, 1, "Doe")
DatabaseUpdate(0, "INSERT INTO users (firstname, lastname) VALUES (?, ?)")
CloseDatabase(0)
Thanks!