Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have this bug that is driving me crazy.

I have a application in Winforms. In my 'FORM LOAD' event, i connect to my oracle database. The there is a button i press to load data from the database.

Randomly, 1 in 8 times, when i click the button , its bugs out 'cannot execute datareader when connection closed'. But if i open the application a sec later it works again.

Any suggestions

Nicole
Posted
Comments
Christian Amado 1-Apr-14 8:37am    
Can you share the code snippet here?

1 solution

This error could be generated by the fact that you are forgot to dispose the used resources, in your case the data reader and the database connection. So you should use try-catch-finally block to manage the access at the database data, and in finally to close the used reader then the database connection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900