1

How to use two databases at a time? They are placed at different networks. Is it possible in .net?

Thaven
  • 1,857
  • 3
  • 19
  • 35
Sravanti
  • 1,409
  • 4
  • 22
  • 45
  • are you planning to update them within a single transaction? – govi Feb 22 '12 at 11:11
  • S @govi how to acheive this.they are at different locations[networks]. – Sravanti Feb 22 '12 at 11:51
  • hmm.. i havent tried these, but there is http://stackoverflow.com/questions/1063502/how-to-implement-transaction-over-multiple-databases and the whole bunch of links in there. Are they helpful? – govi Feb 22 '12 at 12:49

2 Answers2

1

If you want a Transaction that spans multiple databases you can use a TransactionScope.

using (TransactionScope t = new TransactionScope())
{
    // Execute code
    t.Commit();
}

The Transaction will be promoted to a distributed transaction when necessary. You need to make sure that the Distributed Transaction Coordinator is installed and then everything will work without further configuration.

Wouter de Kort
  • 39,090
  • 12
  • 84
  • 103
1

Use DataMirroring concept in Sqlserver.

Sravanti
  • 1,409
  • 4
  • 22
  • 45