vendredi 13 mars 2015

CREATE TABLE IF NOT EXISTS statement in SQLite

I have a WPF application where I access a SQLite database via ADO.NET (http://ift.tt/1BdUkBp). So far everything works fine. But when I try to execute the following SQL:



sqlite_cmd.CommandText = "CREATE TABLE IF NOT EXISTS notes (id integer primary key, text varchar(100));";
sqlite_cmd.ExecuteNonQuery();


I get the following exception:


An exception of type 'Finisar.SQLite.SQLiteException' occurred in SQLite.NET.dll but was not handled in user code. Additional information: near "NOT": syntax error


When I remove the "IF NOT EXISTS" part it works fine. But I want to create the table only if it is not already there. Is there anything I'm doing wrong? Thanks in advance!


Aucun commentaire:

Enregistrer un commentaire