RE: ado.net begin informix transaction
Posted in 2005
Topics: Security, Permissions & Auditing
You're second example is the correct way to handle transactions in ADO.NET. But why not use the Informix .Net Provider that comes with the Client SDK? From the "IBM Informix .NET Provider Reference Guide", version 2.90: IfxConnection myConn = new IfxConnection("Host=ajax;Server=myServer; Service=9401;database=dotnet;user id=xxx;password=xxx"); myConn.open(); IfxTransaction myTrans = myConn.BeginTransaction(); IfxCommand myCommand = new IfxCommand(); MyCommand.Transaction = myTrans; MyCommand.CommandText = "INSERT INTO mytab(custid,custname) values(1005,\\"Name\\");" MyCommand.ExecuteNonQuery(); MyTrans.Commit(); MyConn.Close(); This method has been working well for us. Thanks, Sean. -----Original Message----- From: owner-informix-list@iiug.org [mailto:owner-informix-list@iiug.org] On Behalf Of kliu Sent: Thursday, November 10, 2005 3:24 PM To: informix-list@iiug.org Subject: ado.net begin informix transaction Hi, Is there any one used the following way to open a INFORMIX transaction in ADO.NET? OleDbConnection conn = new OleDbConnection(connString); OleDbCommand cmd = new OleDbCommand("Begin Work", conn); cmd.ExecuteNonQuery(); //....Do the other works .....// cmd = new OleDbCommand("Commit Work", conn); Or OleDbConnection conn = new OleDbConnection(connString); OleDbTransaction trans = conn.BeginTransaction(); OleDbCommand cmd = new OleDbCommand("Update XXX", conn); //Please notice that the transaction object is not passed in.. cmd.ExecuteNonQuery(); trans.Commit(); This is not followed the way how ADO.NET handles the transaction. But it works. Does anyone know if the above code will have any problem? Thanks. sending to informix-list
Thanks for your reply. Regarding the second example, I didn't pass in the transaction object into the command object. That is the key point. And at the end, if the transaction object got committed. It works. (Note, this way doesn't work on SQL Server or other databases). The reason of not using IBM Informix .Net Provider is that there are too many changes in our project.