|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Filling from inside a transaction?How can one fill a DataSet or DataTable from inside a transaction? I'm
receiving an exception when the following Fill method is executed. DataTable dt = new DataTable(); OracleDataAdapter da = new OracleDataAdapter("SELECT * FROM dual", conn); da.Fill(dt); ### EXCEPTION ### Execute requires the Command object to have a Transaction object when the Connection object assigned to the Command is in a pending local transaction. The Transaction property of the Command has not been initialized.
Show quote
"Mike King" <emai***@excite.com> wrote in message I solved my problem by using a DataReader.news:eaZanQFpGHA.1548@TK2MSFTNGP04.phx.gbl... > How can one fill a DataSet or DataTable from inside a transaction? I'm > receiving an exception when the following Fill method is executed. > > DataTable dt = new DataTable(); > OracleDataAdapter da = new OracleDataAdapter("SELECT * FROM dual", conn); > da.Fill(dt); > > ### EXCEPTION ### > Execute requires the Command object to have a Transaction object when the > Connection object assigned to the Command is in a pending local > transaction. The Transaction property of the Command has not been > initialized. cmd = new OracleCommand(); cmd.CommandText = "select * from dual"; cmd.Connection = conn; cmd.Transaction = trans; IDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { //... do the magic rdr.GetString(0); } Just set the OracleTransaction you have to the
OracleDataAdapter.SelectCommand.Transaction property and the below should work fine. - Sahil Malik [MVP] http://blah.winsmarts.com Show quote "Mike King" <emai***@excite.com> wrote in message news:eaZanQFpGHA.1548@TK2MSFTNGP04.phx.gbl... > How can one fill a DataSet or DataTable from inside a transaction? I'm > receiving an exception when the following Fill method is executed. > > DataTable dt = new DataTable(); > OracleDataAdapter da = new OracleDataAdapter("SELECT * FROM dual", conn); > da.Fill(dt); > > ### EXCEPTION ### > Execute requires the Command object to have a Transaction object when the > Connection object assigned to the Command is in a pending local > transaction. The Transaction property of the Command has not been > initialized. > > > "Sahil Malik [MVP C#]" <contactmethrumyblog@nospam.com> wrote in message Thanks!news:ObbLEkFpGHA.5104@TK2MSFTNGP04.phx.gbl... > Just set the OracleTransaction you have to the > OracleDataAdapter.SelectCommand.Transaction property and the below should > work fine. > > - Sahil Malik [MVP] > http://blah.winsmarts.com |
|||||||||||||||||||||||