How to make sure all query good than only commit, else rollback

  • Thread starter Thread starter Ashokkumar9892
  • Start date Start date
A

Ashokkumar9892

Guest
Hi,

I have scenario , like i need to update three servers data,

so i have multiple insert queries, which i am running using C# ad.net.

like Below, i want to rollback if any queries fail or any issue in inserting, please advice me.

actually if successfully done than in all else not in single one, this query also using Oracle Dblink. Below is code.

try

{

foreach(string strcon in connectionstring)

{

string service_name =tnreg.get(strCon, "service_name");

string query = query with servicename , like "Insert into Server@servicename values"

transaction = connection.beignTransaction();

command.Transaction = transaction;

command.CommandType =CommandType.text;

Command.CommandText = query;

command.ExecuteNoQuery();

Transaction.commit();

}

}catch(exception ex)

{

transaction.Rollback();

}









Jumping

Continue reading...
 
Back
Top