Any idea why the code below is coming back with Unable to Prepare Statement
mDatabase.ActiveDatabase is an open database at the point the following is called.
[code]
Dim sSQL As String
Dim ps As SQLitePreparedStatement
sSQL = “INSERT INTO tblContacts(supplier,name,address,postcode,phone,mobile,email,website) VALUES (?, ?, ?, ?, ?, ?, ?, ?)”
ps = mDatabase.ActiveDatabase.Prepare(sSQL)
ps.SQLExecute(1,“aa”,“aa”,“aa”,“aa”,“aa”,“aa”,“aa”)//Just test data ignore what it is.
if mDatabase.ActiveDatabase.Error then
MsgBox ActiveDatabase.ErrorMessage
end if
[quote=72130:@Norman Palardy]table name is correct ?
column names are correct ?
I can’t think of anything else[/quote]
Yes and yes. It’s got me stumped.
I think that is just for SELECTS or at least it is according to the UserGuide-Framework.pdf page 129. I would expect to bind the types normally in PHP but the user guide suggests not??? Bamboozled
I did some testing, and you may have a problem with your table.
If I create the database and just try to prepare the statement, i.e., before creating a table or fields, I get the message you got. After I create the table and fields, I get the message “Bind types were not specified, see BindType”.
dim db as new SQLIteDatabase
Dim sSQL As String
Dim ps As SQLitePreparedStatement
if not db.Connect() then
AddToResult "Couldn't connect."
return
end if
sSQL = "CREATE TABLE tblContacts ( supplier INTEGER, name TEXT, address TEXT, postcode TEXT, phone TEXT, mobile TEXT, email TEXT, website TEXT )"
db.SQLExecute sSQL
if db.Error then
AddToResult db.ErrorMessage
return
end if
sSQL = "INSERT INTO tblContacts(supplier,name,address,postcode,phone,mobile,email,website) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
ps = db.Prepare(sSQL)
if db.Error then
AddToResult db.ErrorMessage
return
end if
ps.SQLExecute(1,"aa","aa","aa","aa","aa","aa","aa")//Just test data ignore what it is.
if db.Error then
AddToResult db.ErrorMessage // This is where we detect an error
return
end if
Aha… I think I may have been leading myself and everyone else up the garden path. Thanks Peter, my latest error message is The Operation Cannot be completed because the database is closed. I’m not sure why it is closed so I will investigate this and get back to you… Whoops