Filling from inside a transaction?

M

Mike King

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.
 
M

Mike King

Mike King said:
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.

I solved my problem by using a DataReader.

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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top