Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Connection must be open for this operation" Exception.

447273Jul 21 2005 — edited Jun 20 2011
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2011
Added on Jul 21 2005
18 comments
38,210 views