I have a WinForm application querying SqlCe database using typed-dataset tabledapters. I have a main form assembly and a database assembly which handles every db operation. I'm having problems with updating using tableadapter in a transaction and I'd appreciate if anyone could give me any ideas why.
Update() method gives this error:
"The connection object can not be enlisted in transaction scope."
Here's my code:
namespace Main
{
public class MainForm
{
private MyDbAssembly.MyDbClass db;
//instantiate and db fill methods omitted..
private void DeleteStuff()
{
using (TransactionScope trans = new TransactionScope())
{
this.db.Delete(id);
UpdateDb();
trans.Complete();
}
}
private void UpdateDb()
{
//bindingsource endedit & datagridview endedit methods omitted..
this.db.Update();
}
}
}
namespace MyDbAssembly
{
public class MyDbClass
{
private myTypedDataset myDataSet;
private myTypedDataSetTableAdapter.MyTable1Adapter table1Adapter;
//instantiate methods omitted..
public void Delete(Guid id)
{
this.myDataSet.MyTable1.FindByID(id).Delete();
}
public void Update()
{
this.table1Adapter.Update(myDataSet.MyTable); //<-- ERROR LINE
}
}
}