Connection must be open for this operation" Exception.
447273Jul 21 2005 — edited Jun 20 2011Hi,
Iam trying to access oracle10g through .net,using ODP.Net (Provider version 10.1.0.400 ).
Iam getting the following error "An unhandled exception of type 'System.InvalidOperationException' occurred in oracle.dataaccess.dll" and "Additional information: Connection must be open for this operation", while iam attempting to invoke ExecuteReader/ExecuteScalar methods on a OracleCommand Object.
requrest you all to kindly let me know as to how to solve this.
This is the sample come iam using
OracleConnection Conn = new OracleConnection("Data Source=ORCL;User Id=Scott;Password=tiger");
OracleCommand cmd = new OracleCommand("Select * from Emp",Conn);
Conn.Open();
cmd.CommandType=System.Data.CommandType.Text;
OracleDataReader dr= cmd.ExecuteReader();
MessageBox.Show(dr.RecordsAffected.ToString());
Thanks
Sundeep