Hello.
The following code works perfectly:
var oDb = new SQLiteConnection();
oDb.ConnectionString = String.Format(
"Data Source={0};"
+ "Synchronous=Full;",
"test.db" );
oDb.Open();
SQLiteCommand oCmd = new SQLiteCommand( oDb );
oCmd.CommandText = "create table tests ( ";
oCmd.CommandText += " id guid primary key not null";
oCmd.CommandText += ", name text default 'none' )";
oCmd.ExecuteNonQuery();
But if i try to use a query builder (to automatically escape strings):
var oDb = new SQLiteConnection();
oDb.ConnectionString = String.Format(
"Data Source={0};"
+ "Synchronous=Full;",
"test.db" );
oDb.Open();
SQLiteCommand oCmd = new SQLiteCommand( oDb );
oCmd.CommandText = "create table tests ( ";
oCmd.CommandText += " id guid primary key not null";
oCmd.CommandText += ", name text default @param )";
var oParam = new SQLiteParameter( "@param", "none" );
oCmd.Parameters.Add( oParam );
oCmd.ExecuteNonQuery();
Exception is raised:
SQLite error
near "@param": syntax error
Can anyone please spare a bit of knowledge and hint me what i'm doing wrong?