Does SQL Server CE support System.Transactions?
Hi,
I've tried to enclose a few database operations in a TransactionScope block but it looks like SQL Server CE RM does ignores ambiental transaction.
Here is the code:
staticvoid TestTxn(){// Command to insert an integer in a table with a single integer column
string cmdPassText ="INSERT TESTTABLE (INTFIELD) VALUES(1)";
// Command to force field type mismatch exception
string cmdFailText ="INSERT TESTTABLE (INTFIELD) VALUES('Foo')";
using (TransactionScope scope =newTransactionScope()){
using (SqlCeConnection conn =newSqlCeConnection("DataSource = 'Test.sdf'")){
try{
conn.Open();
SqlCeCommand cmdPass =newSqlCeCommand(cmdPassText, conn);
returnValue = cmdPass.ExecuteNonQuery();
SqlCeCommand cmdFail =newSqlCeCommand(cmdFailText, conn);
returnValue = cmdFail.ExecuteNonQuery();
}
catch (Exception ex){
Console.WriteLine("Command failed");
Console.WriteLine("Exception Message: {0}", ex.Message);
}
}
scope.Complete();
}
}
After first command suceeds and seccond command failes table still has one affected row after transaction.
Am I doing something wrong or System.Transactions.Transaction is not supported with SQL Server CE RM?
Thanks,
Aleksandar

