I have a little problem. I’m trying to create a generic database routine that I can pass different dictionaries of data to and it will handle the database submissions for me. This is for iOS by the way.
I have my SQL that looks like this:
INSERT OR REPLACE INTO users (ID, cloud_id, username, ipad_pin, title, firstname, lastname, status, created, modified, archived, access_group_id, expiry, useexpiry) VALUES ( (SELECT ID FROM users WHERE cloud_id = ?1), ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14);
This string is compiled based on a list of fields that are passed to the function. So the number of ?X can change.
I build an array of all the params I wish to pass to the DB (arrParams() as Auto) and execute:
App.datasrc.SQLExecute(sql, arrParams)
I then receive the error:
InvalidArgumentException
Arrays are not valid SQLite types
I notice on the Eddies Electronics example you are passing the params like this:
App.EEDB.SQLExecute(sql, FirstName, LastName, Address, City, State, Zip, Phone, Email, Taxable, ID)
So it is not using an array of values and instead passing each one as a separate variable. I can’t however do this as I don’t know what data I will have to submit or how many items it will be, so I can only submit it as an array.
The documentation for iOS says:
SQLExecute(sqlstatement As Text, ParamArray values() As Auto)
So I’m assuming I am able to submit the params as an array? Or am I missing something? Is the documentation wrong and am I going to have to do this differently?
Any help appreciated, or advice on another way I can do this that works.