Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Connection must be open for this operation" #626

Open
egithubh opened this issue Oct 25, 2021 · 2 comments
Open

"Connection must be open for this operation" #626

egithubh opened this issue Oct 25, 2021 · 2 comments

Comments

@egithubh
Copy link

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
Copy link
Author

egithubh commented Dec 2, 2021

Still have this problem :/

@asherber
Copy link
Collaborator

asherber commented Dec 2, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants