Maximum open cursor reached issue in application connecting to Oracle database

Hi Experts,

I'm having an issue of oracle cursor in my application. I'm using Oracle connection to connect to Oracle DB, and have a transaction. Within transaction there are insert and select statement. When oracle reaches to its maximum cursor defined in oracle DB, it's throwing an exception of "Maximum open cursor reached" in application.  

Since I'm using transaction, I cannot close the connection until transaction is done. I don't know why "ExecuteNonQuery" is creating a new cursor. If i have 1000 records in transaction, it's opening 1000 cursor in the DB, one cursor for each "ExecuteNonQuery"

Is there any way to avoid this cursor issue? I already tried disposing the command object but no luck.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark GeerlingsDatabase AdministratorCommented:
I don't use VB, so I can't help you inside VB.  But, could you write your code in PL\SQL instead and compile it as a stored procedure that can accept input parameters, then call that procedure from your application?
ArikkanAuthor Commented:
The issue is not with Input parameter. It's creating cursor for each "ExecuteNonQuery" function. even if we use stored procedure "ExecuteNonQuery" needs to be executed.
Mark GeerlingsDatabase AdministratorCommented:
But, if all of the logic is in PL\SQL instead of in VB, you may need to make only one call to "ExecuteNonQuery", that is, assuming you can pass the values needed to PL\SQL in the one procedure call.  Or, you may be able to create and populate  a "work" table with the parameter values you need, then have the PL\SQL procedure use a cursor loop to fetch each set of values from the work table and do the Oracle processing that you need.
ArikkanAuthor Commented:
It was an issue with ExecuteDataReader, and closing the datareader object solved the issue.

Thanks everyone for your help..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ArikkanAuthor Commented:
I did resolve it by myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.