I try to run the following code:
SqlCeEngine engine = new SqlCeEngine( connStr );
engine.CreateDatabase( );
SqlCeConnection conn = null;
conn = new SqlCeConnection( connStr );
conn.Open( );
string eh =
@"Create table test(ID INT IDENTITY NOT NULL PRIMARY KEY, DateTest DATETIME);
Create table test2(ID INT IDENTITY NOT NULL PRIMARY KEY, DateTest DATETIME);";
SqlCeCommand hm = new SqlCeCommand(eh, conn);
hm.ExecuteNonQuery();
However when I try to do an ExecuteNonQuery I get the following exception:
{There was an error parsing the query. [ Token line number = 2,Token
line offset = 1,Token in error = Create ]}
Any ideas what could be causing this to happen?
You have to execute each command separately.
If you want them to all succeed or fail together, then you need to wrap everything in a transaction.