Maybe someone can shed some light on this...
When testing the following code on my PPC 2003 emulator it works fine.
However, when testing it on a PPC 2003 device, it does not. Specifically, the
delete command runs fine, but i get an error on the insert command text line
(that is, the error throws before the insert command executes?):
cn = new SqlCeConnection(<< connection string >>);
cn.Open();
cmd = new SqlCeCommand();
cmd.Connection = cn;
cmd.CommandText = "<< delete string >>";
cmd.ExecuteNonQuery();
cmd.CommandText = "<< insert string >>";
cmd.ExecuteNonQuery();
cn.Close();
In the above example, the command object has class-level scope. Maybe this
is the problem? However, i was able to make the following code work on both
the emulator and actual device:
// Connection Objects
cn = new SqlCeConnection(<< connection string >>);
cn.Open();
string sql_delete = << Delete string >>;
SqlCeCommand sqlCmdDelete = new SqlCeCommand(sql_delete, cn);
sqlCmdDelete.CommandType = CommandType.Text;
sqlCmdDelete.ExecuteNonQuery();
string sql_insert = << Insert String >>
SqlCeCommand sqlCmdInsert = new SqlCeCommand(sql_insert, cn);
sqlCmdInsert.CommandType = CommandType.Text;
sqlCmdInsert.ExecuteNonQuery();
cn.Close();
If anyone can explain why the first code snippet works on the emulator and
not on teh deive, i would be appreciative. And, do command objects need to be
explicitly destroyed? Thanks.