如何确保活动顺序 [英] How to ensure order of events

查看:84
本文介绍了如何确保活动顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有这个让我疯狂的错误。



我有一个在Winforms中的应用程序。在我的'FORM LOAD'事件中,我连接到我的oracle数据库。有一个按钮我按下来从数据库加载数据。



随机,1次8次,当我点击按钮时,它的错误'无法执行datareader当连接关闭'。但如果我在一段时间后打开应用程序它会再次运行。



任何建议



Nicole

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

推荐答案

这个错误可能是因为您忘记处理已使用的资源,在您的情况下是数据读取器和数据库连接。所以你应该使用 try-catch-finally 块来管理数据库数据的访问,最后到关闭用过的阅读器然后是数据库连接。
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.


这篇关于如何确保活动顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆