Still having problems with transactions.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top