Kevin Piciulo wrote:
Can I add a column using a variable for the column name? Below is
the prepare statement, which is returning an error.
sqlite3_prepare(m_dbDataBase, "ALTER TABLE users ADD COLUMN ?
varchar;", -1, &stmt, NULL);
I'm pretty sure my syntax is correct which leads me to believe you
cannot do this. If that's the case is there some sort of work around?
Kevin,
You are correct, this is illegal. You can only use a parameter where an
"expression" is allowed in the SQL syntax. Parameters do not do string
substitution in the SQL. You can check if your SQL still makes sense by
substituting a simple sum expression for your parameter. In your case,
the following does not make sense.
ALTER TABLE users ADD COLUMN 5+2 varchar;
HTH
Dennis Cote