I have some code that uses ODP.Net
using (OracleConnection connection = new OracleConnection(connectionString))
{
connection.Open();
boxCommand = new OracleCommand(sql, connection);
OracleDataAdapter boxAdapter = new OracleDataAdapter(boxCommand);
DataTable boxTable = new DataTable();
boxAdapter.Fill(boxTable);
}
I then get an error below on a production server. The test server is fine.
I don't understand as its complaining about a connection not being open but if there was a problem it should occur at the point my Open
is called not on the Fill
. Also I thought Fill
was supposed to open the connection anyway.
Can anyone suggest what might be going on?
UPDATE: From the comments I tried adding this but same problem:
using (OracleConnection connection = new OracleConnection(connectionString))
{
connection.Open();
while(connection.State != ConnectionState.Open)
{
connection.Close();
connection.Open();
}
boxCommand = new OracleCommand(sql, connection);
OracleDataAdapter boxAdapter = new OracleDataAdapter(boxCommand);
DataTable boxTable = new DataTable();
boxAdapter.Fill(boxTable);
}
UPDATE 2 : I have added logging and the Validate Connection = true to the connection string and I know the connection state is open, the box command was done, the adapter created and the table created, it definitely errors on the Fill