Hi there, Kem.
I took all the good folks advice and started playing with prepared statements before modifying my main program.
I can read with no problem from my database with a select, but I can’t insert.
Here is the code where I have 2 textfields and 1 area that I can enter data in… for checking the apostrophe. The commented out items are for future testing. I’m just using textfield1 to work out the bugs…
// new test of preparedSQL statement for insert
dim db as SQLiteDatabase
dim dbfile as FolderItem
dim rows as integer
dim i as integer
dim workRS as Recordset
Var ps As SQLitePreparedStatement
dbfile = getopenFolderItem("")
if dbfile <> NIL then
db = new SQLiteDatabase
db.DatabaseFile = dbfile
if db.Connect then
MessageBox "Connected"
ps = SQLitePreparedStatement(db.Prepare("INSERT INTO Activity (groupType, Name, startTime, endTime, Notes, seconds, minutes, hours, tech3, tech2, tech1) VALUES (?,?,?,?,?,?,?,?,?,?,?"))
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(2, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(3, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(4, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(5, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(6, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(7, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(8, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(9, SQLitePreparedStatement.SQLITE_TEXT)
'ps.BindType(10, SQLitePreparedStatement.SQLITE_TEXT)
ps.Bind(0, TextField1.Text) // for group, with an apostrophe
'ps.Bind(1, TextField2.Text) // for name with apostrophe
'ps.Bind(2, "2021-04-13 21:20:20") //start time
'ps.Bind(3, "2021-04-13 22:20:20")//end time
'ps.Bind(4, TextArea1.Text) //notes with apostrophe
'ps.Bind(5, "600") //seconds
'ps.Bind(6, "10") //minutes
'ps.Bind(7, "0.166666") //hours
'ps.Bind(8, "Fred Flintstone") //techname
'ps.Bind(9, "000-000-0001") //cell phone
'ps.Bind(10, "000-000-0002")// office phone
ps.SQLExecute ()
end if
end if
Can you see what boneheaded mistake I’m making?
Regards