E
Eli Markov
Hi,
I have a problem with SqlCeTransaction. After I commit or
rollback a transaction, nothing is being written to the
database, unless I close the connection after the
commit/rollback.
I have seen some post regarding this problem in the pre
RTM versions, but I use the version which comes with the
VS.NET 2003.
The second question is, how do I work with nested
transaction, I always get the exception: "parallel
transactions are not supported".
Here is the code for the first part:
int cnt;
SqlCeTransaction trans1;
SqlCeCommand SQLCmd;
SqlCeConnection cnn = new
System.Data.SqlServerCe.SqlCeConnection(@"Data Source =
\MyDB.sdf");
try
{
cnn.Open();
trans1 = cnn.BeginTransaction();
SQLCmd = new SqlCeCommand("INSERT INTO myTbl values
(1, 'string 1')", cnn, trans1);
cnt = SQLCmd.ExecuteNonQuery();
trans1.Commit();
trans1.Dispose();
SQLCmd.Dispose();
SQLCmd = new SqlCeCommand("INSERT INTO myTbl values
(2, 'string 2')", cnn);
cnt = SQLCmd.ExecuteNonQuery();
}
catch(Exception ex)
{
throw ex;
}
finally
{
cnn.Close();
}
Thanks
Eli
I have a problem with SqlCeTransaction. After I commit or
rollback a transaction, nothing is being written to the
database, unless I close the connection after the
commit/rollback.
I have seen some post regarding this problem in the pre
RTM versions, but I use the version which comes with the
VS.NET 2003.
The second question is, how do I work with nested
transaction, I always get the exception: "parallel
transactions are not supported".
Here is the code for the first part:
int cnt;
SqlCeTransaction trans1;
SqlCeCommand SQLCmd;
SqlCeConnection cnn = new
System.Data.SqlServerCe.SqlCeConnection(@"Data Source =
\MyDB.sdf");
try
{
cnn.Open();
trans1 = cnn.BeginTransaction();
SQLCmd = new SqlCeCommand("INSERT INTO myTbl values
(1, 'string 1')", cnn, trans1);
cnt = SQLCmd.ExecuteNonQuery();
trans1.Commit();
trans1.Dispose();
SQLCmd.Dispose();
SQLCmd = new SqlCeCommand("INSERT INTO myTbl values
(2, 'string 2')", cnn);
cnt = SQLCmd.ExecuteNonQuery();
}
catch(Exception ex)
{
throw ex;
}
finally
{
cnn.Close();
}
Thanks
Eli