Reputation:
I have a problem with my code, I want turn on the foreign keys but I got error messages. I am using SQLitePCL installed with nuget, and I added SQLite for UWP as reference.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var parameter = e.Parameter as string;
if (parameter != null && parameter.Equals("new"))
{
SQLiteConnection dbConnection = new SQLiteConnection("New.db");
string Head_Create = @"CREATE TABLE IF NOT EXISTS Head
(ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, A TEXT
, B TEXT
, C TEXT
, D TEXT
, E TEXT
);";
ISQLiteStatement cnStatement_Head1 = dbConnection.Prepare(Head_Create);
cnStatement_Head1.Step();
string SQLite_Metrados_Head_Pragma = @"PRAGMA foreign_keys = ON";
ISQLiteStatement cnStatement_Head2 = dbConnection.Prepare(SQLite_Metrados_Head_Pragma);
cnStatement_Head2.Step();
I got the error in the line:
ISQLiteStatement cnStatement_Head2 = dbConnection.Prepare(SQLite_Metrados_Head_Pragma);
Additional information: Unable to prepare the sql statement: PRAGMA foreign_keys = ON Details: near "PRAGMA foreign_keys": syntax error
It seems like a syntax error but I am writing the correct string for foreign keys dude, I was testing with the string:
@"PRAGMA foreign_keys = ON;"
But it get error too.
Any help with my string (or the correct string for turn on the foreign keys in sqlite) is appreciated.
Upvotes: 0
Views: 976
Reputation: 180080
near "PRAGMA foreign_keys": syntax error
The thing quoted after "near" should be a single word. So in this case, the space character is not actually a normal space character but something else, such as a non-breaking space.
Upvotes: 1