c# - Get hang on when query data -


I am using source code like this:

  database db1 = new database (); // init 1db connection db1.bigtitrainsignation (); // This function is used to view the client present / present in this function, I also use the database db2 = new database (); Db2.Close (); CheckExistCustomer (); InsertCustomer (db1, strInsert); // This function works fine, use DB1 if (iErrorCode == ErrorStatus.SUCCESSED) db1.CommitTransaction (); Second DB1 Rollback transaction ();   

As you see, I have 2DB connections, can I use them? When db2.Close (), it will not affect current DB1, right? Should I Use Only 1 DB Connection (DB1)?

When I run CheckExistCustomer (), the program will hang out. I do not know why any clue?

Please advise.

I'm very epiactive to help you.

You are managing transactions in this code. In the transaction, you are operating on two DBs, it is called Distributed Transactions, I think the BeginTransaction () method does not support distributed transactions, please use the TransactionScope class

< / P>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -