Hello everybody!
Does anybody know how can I use the same sql transaction object for several sql connections? For example I need to copy data from Server1 to Server2 and Server3 and if somthing failed in copying then to rollback everything.
So I have:
SqlConnection connFrom = new SqlConnection(...);
SqlConnection connTo1 = new SqlConnection(...);
SqlConnection connTo2 = new SqlConnection(...);
SqlTransaction trans;
try
{
trans = connTo1.BeginTransaction();
...
// some stuff
// and here I need to change connection for this transaction
...
trans.Commit();
}
catch (SqlException ex)
{
trans.rollBack();
}
finally
{
connFrom.close();
connTo1.close();
connTo2.close();
}
How should it be done?
Thank you,
Alex
Does anybody know how can I use the same sql transaction object for several sql connections? For example I need to copy data from Server1 to Server2 and Server3 and if somthing failed in copying then to rollback everything.
So I have:
SqlConnection connFrom = new SqlConnection(...);
SqlConnection connTo1 = new SqlConnection(...);
SqlConnection connTo2 = new SqlConnection(...);
SqlTransaction trans;
try
{
trans = connTo1.BeginTransaction();
...
// some stuff
// and here I need to change connection for this transaction
...
trans.Commit();
}
catch (SqlException ex)
{
trans.rollBack();
}
finally
{
connFrom.close();
connTo1.close();
connTo2.close();
}
How should it be done?
Thank you,
Alex