在ASP.Net中使用Ping的数据库运行状态 [英] Database Running status using Ping in ASP.Net

查看:100
本文介绍了在ASP.Net中使用Ping的数据库运行状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,
我要测试运行的Oracle和SQL Server的运行状态为Up或Down.当前,我正在使用以下方式检查连接..例如,Oracle连接为..


I want to test the Oracle and SQL servers running are Up or Down. Currently, I am using the following way to check the connection.. for example Oracle connection as ..

Dim cn As OracleConnection
cn = New OracleConnection(ConnStr)
cn.Open() 


一切正常.但是,还有其他方法可以检查数据库运行状态,例如Ping.
请提出建议.


This is working fine. But, is there any other way to check the DB up status like Ping.
Please suggest.

推荐答案

您可以混合ping服务器IP并与服务器端口进行TCP连接(以查看其是否打开). .但是,尽管这可以确定计算机已启动并且可以通过网络访问,并且数据库服务器正在侦听预期的端口,但是它不能保证数据库处于稳定状态,因为您确实需要尝试建立像上面一样进行数据库连接.
You could do a mix of pinging the server IP and also doing a TCP connection to the server port (to see if it''s open). But while that would establish that the machine is up and accessible over the network, and that the database server is listening on the expected ports, it does not guarantee that the database is in a stable condition, for that you do need to actually try establishing a database connection as you are doing above.


您的方向正确.您也可以检查连接状态

You are in the right direction. You can check for the connection state as well

Dim cn As OracleConnection
cn = New OracleConnection(ConnStr)
cn.Open()
If (cn.State And ConnectionState.Open) > 0 Then
    'Do whatever you want
    cn.Close()
Else
    'Oops, it an't open
End If


这篇关于在ASP.Net中使用Ping的数据库运行状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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