problem in commit & roll back [modified]
-
Hi anybody pls help me its very urgent I am facing a problem while doing commit & roll back in one of my pages. My problem is i have to upload data from one database(accounts) to another say Gaccounts programmatically. In my web.config i wrote 2 connections by name con(for database accounts), con1(for Database-Gaccounts). Then in my program i am using commit & roll back. I have to check the code from ledger table (say 0003) with code in accounts table if it exist then i have to check whether that code exits in accounts table of gaccounts database. If it is not there I have to add more value in the code like (0003tvm) and then create a row in accounts table of gaccounts database with this new code. This much am not feeling any problem. Now I have to update this new code back in accounts table of accounts database. .here the problem comes if roll back happens then also updating of this code take place Creating complete error .I am giving database details in a class file. In this project I used 2 class files say objdb-representing accounts and objmdb-for gaccounts. ‘This is the code I am using for roll backing Dim objCon1 As New oleDbConnection(ConfigurationSettings.AppSettings.Get("con1")) Dim objCmd As New OleDbCommand Dim objTran As OleDbTransaction objCon1.Open() objTran = objCon1.BeginTransaction objCmd.Connection = objCon1 objCmd.Transaction = objTran Try ****** I have given the code for updating as ******* 'sSQL = " Update accounts set txtmastcode='" & snewcode& "'WHERE txtcode='" & objdr("txtcode") & "'" ireturn=objdb.executenonquerry(ssql,objdb.opendb) objTran.Commit() Catch ex As Exception objTran.Rollback() MessageBox.Show("Transaction failed. Contact Administartor") MessageBox.Show(ex.Message().ToString()) Finally objCon1.Close() objCmd.Dispose() End Try Please anybody help me , this is very urgent. -- modified at 13:25 Wednesday 24th January, 2007