我正在开发我公司的一个旧项目,用 VB.NET 编写(整个应用程序中没有 try catch 块 * 叹气 *)。基本问题是它留下了僵尸进程。
我怀疑的是它使用的数据库调用,即 ADODB 连接对象来查询 sql 数据库。
adoConn.Open("DSN=NameOfDatabase;UID=NameOfSA;PWD=password")
Run Code Online (Sandbox Code Playgroud)
我在想的是引入一个简单的数据库状态检查。使用
adoConn.State
(int)
但我不确定 adoConn.State 的可能值是什么。我已经检查过https://msdn.microsoft.com/en-us/library/adodb._connection.state%28v=vs.90%29.aspx但没有此类信息。
我精通 C# 所以我虽然它会像
0:关闭
1:连接
2:连接等
任何此类信息(带有适当的引文)都会非常有帮助。
State
属性 (ADO) 指示所有适用对象的状态是打开还是关闭。如果对象正在执行异步方法,则指示对象的当前状态是连接、正在执行还是正在检索。
返回一个可以是一个ObjectStateEnum
值的 Long值。默认值为adStateClosed
。
Constant Value Description
adStateClosed 0 Indicates that the object is closed.
adStateOpen 1 Indicates that the object is open.
adStateConnecting 2 Indicates that the object is connecting.
adStateExecuting 4 Indicates that the object is executing a command.
adStateFetching 8 Indicates that the rows of the object are being retrieved.
Run Code Online (Sandbox Code Playgroud)