连接状态即使打开也将关闭 [英] Connection state is closed evenif it is opened

查看:64
本文介绍了连接状态即使打开也将关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用3层架构.
有用于处理保存& amp;的db类.删除例程,而我正在页面类中的事件中调用这些例程.
在db类中.
1.连接打开,
2.交易已初始化以开始交易
3.调用保存或删除程序
4.如果成功提交事务,则回退事务
5.连接已关​​闭.
当我运行网站并保存连接时,打开连接,并在调用页面类以获取连接状态时关闭.且转换对象为Nothing

I am using 3 tier architecture.
There is db class for handling saving & deleting routines and i am calling these routine<s in the events in page class.
In db class.
1.connect opened,
2. transaction initialized to begin transaction
3. calling the procedures for saving or deletion
4. if success transaction committed else transaction rollbacked
5. connection closed .
When i am running the website and saving the connection opened and while calling the page class for the connection status is closed. and the transction object is get Nothing

推荐答案

关闭连接后是否要返回DataReader?

如果是这样,那么您就不能这样做.您将需要确保您的类实现了 IDisposable .

这样,您将可以执行使用,然后在清理连接时将其关闭,并且还记得在所有捕获中都关闭了该连接.
Are you trying to return a DataReader after you have closed your connection?

If so, well, you cant do that. You will need to ensure that you class implements an IDisposable.

That way you will be able to perform a Using and then on clean up close the connection and also remember to close the connection in any catches.


这篇关于连接状态即使打开也将关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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