Richard Boyd wrote:

I tried what you suggested and I always get the error message:
"SQL error: no such column: table32"
Whether the table exists or not, I always get returned value of 1 from
sqlite3_exec().

The exact command that I use is:
SELECT count(*) FROM sqlite_master WHERE name=table32 AND type='table';


If you don't quote "table32", then the database thinks you're trying to compare the value in the "name" column to the value in the "table32" column, which doesn't exist.

I also tried single quotes around the table32 name:
SELECT count(*) FROM sqlite_master WHERE name='table32' AND type='table';
And get no errors whether the table exists or not....


Good, that's correct.

When I try the other method suggested ("SELECT NULL FROM sqlite_master WHERE
tbl_name = 'your-table';") I don’t get any error messages whether the table
exists or not. The return value is always 0.


SQLITE_OK is zero, so that means the query succeeded.

I'm obviously missing where the error is being flagged, have you any more
pointers?
Sorry if I'm being dense here but I'm new to SQL databases.


You need to check the returned data. The first query returns a result set containing a single row with one value, the number of tables named "table32"... The second query returns one or more rows containing a single NULL value if a table named "table32" exists or any empty result set if it doesn't.
--
http://www.velocityvector.com/ | http://glmiller.blogspot.com/
http://www.classic-games.com/ |
"We have declared a fierce war on this evil principle of
democracy and those who follow this wrong ideology,"
-- Abu Musab al-Zarqawi

Reply via email to