PetaPoco icon indicating copy to clipboard operation
PetaPoco copied to clipboard

"Connection must be open for this operation"

Open egithubh opened this issue 4 years ago • 2 comments

Hey,

I use PetaPoco 5.1.306 together in an ASP.Net environment running .NET 5. Every few inserts/updates/selects the following happens: I get an error from Oracle.ManagedDataAccess:

System.InvalidOperationException: Connection must be open for this operation
         at Oracle.ManagedDataAccess.Client.OracleCommand.ValidateStatePriorToExecution()
         at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()
         at PetaPoco.Database.ExecuteInsert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco)
         at PetaPoco.Database.Insert(Object poco)

When I check the status of the DB connection before the insert, it says "Open".

What could be the reason for this?

egithubh avatar Oct 25 '21 09:10 egithubh

Still have this problem :/

egithubh avatar Dec 02 '21 12:12 egithubh

So if you check myDb.Connection.State, it says Open? At a glance, that implies that this is some issue with the Oracle provider, not with PP. PP thinks the connection is open, it sends the commend to the Oracle provider, and then the provider says, "Whoops, not open" and throws an exception.

How are you creating your Database object? Are you passing in your own connection, or are you using a connection string?

asherber avatar Dec 02 '21 14:12 asherber