A
Aleksey Timonin
Hi guys,
I tried to use TransactionScope on to defferent TableAdapters like this:
using (TransactionScope transScope = new
TransactionScope(TransactionScopeOption.Required))
{
TableAdapter1.InsertQuery(id, name);
TableAdapter2.InsertQuery(id, customerName, customerAddress);
transScope.Complete();
}
It was failed because each table adapter using it's own connection and
TransactionScope doesn't manage with it...
So I modified my code:
using (TransactionScope transScope = new
TransactionScope(TransactionScopeOption.Required))
{
SqlConnection conn = TableAdapter1.Connection;
conn.Open();
TableAdapter1.InsertQuery(id, name);
TableAdapter2.Connection = conn;
TableAdapter2.InsertQuery(id, customerName, customerAddress);
conn.Close();
transScope.Complete();
}
Am I using TransactionScope correct? And if you see any problem in my code,
let me know.
Thanks a lot
Aleksey
I tried to use TransactionScope on to defferent TableAdapters like this:
using (TransactionScope transScope = new
TransactionScope(TransactionScopeOption.Required))
{
TableAdapter1.InsertQuery(id, name);
TableAdapter2.InsertQuery(id, customerName, customerAddress);
transScope.Complete();
}
It was failed because each table adapter using it's own connection and
TransactionScope doesn't manage with it...
So I modified my code:
using (TransactionScope transScope = new
TransactionScope(TransactionScopeOption.Required))
{
SqlConnection conn = TableAdapter1.Connection;
conn.Open();
TableAdapter1.InsertQuery(id, name);
TableAdapter2.Connection = conn;
TableAdapter2.InsertQuery(id, customerName, customerAddress);
conn.Close();
transScope.Complete();
}
Am I using TransactionScope correct? And if you see any problem in my code,
let me know.
Thanks a lot
Aleksey