如何检测数据库是否可用 [英] How to detect if database is available
本文介绍了如何检测数据库是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个WPF应用程序和一个计时器(30秒)我想检查数据库服务器是否仍然在线。我的应用程序显示图像是否在线(红灯/绿灯)。
我可以创建ADO.NET连接(通过连接字符串)并打开和关闭连接。
如果数据库在线而没有每次都打开和关闭连接,有没有办法检查c#/ WPF?
问候,
Herman
Hi,
I have a WPF application and on a Timer (30 seconds) I want to check if the database server is still ONLINE. My application shows an image t see if it is online or not (red light/green light).
I can create a ADO.NET connection (via connectionstring) and open and close a connection.
Is there a way to check in c#/WPF if the database is online without opening and closing a connection each time?
Regards,
Herman
推荐答案
可以使用
It is possible using
System.Data.Sql.SqlDataSourceEnumerator
这篇关于如何检测数据库是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文