确定SQL Server是否存在 [英] Determine whether SQL Server exists

查看:78
本文介绍了确定SQL Server是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序中包含一个测试连接按钮,用于测试SQL连接字符串的有效性
。我宁愿保持超时

低。这样做的常规方法是什么?

I''d like to include a ''Test Connection'' button in an app, for testing
validity of a SQL connection string. I''d prefer to keep the timeout
low. What is the conventional way of doing this?

推荐答案

你好_DD,


只需连接数据库检查它是否有效


_我想在应用程序中包含一个测试连接按钮,用于测试

_validity of SQL连接字符串。我宁愿保持超时

_low。传统的做法是什么

_>

---

WBR,

Michael Nemtsev: :博客: http://spaces.live.com/laflour


有时一个人仍忠于某一事业,因为它的对手不会因为b $ b不再是平淡的。 (c)Friedrich Nietzsche
Hello _DD,

Just make connection to DB to check whether it valid or not

_I''d like to include a ''Test Connection'' button in an app, for testing
_validity of a SQL connection string. I''d prefer to keep the timeout
_low. What is the conventional way of doing this
_>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


如果你想要一个相对较短的超时,你可以使用ADOX。它是一个COM

库,允许您确定服务器是否存在,数据库是否存在,数据库中的对象等等。我能想到的另一个选项关闭

手就是简单连接并让它失败。


-

Gregory A. Beamer
MVP; MCP:+ I,SE,SD,DBA


**************************** *********************

在盒子外面思考!

******* ****************************************** *

" _dd" < _D*@nospam.com写在留言中

新闻:15 ***************************** *** @ 4ax.com ...
If you want a relatively short timeout, you can use ADOX. It is a COM
library that allows you to determine if a server exists, if a database
exists, the objects in a database, etc. The other option I can think of off
hand is to simply connect and allow it to fail.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...

我想在应用程序中包含一个测试连接按钮,用于测试

SQL连接字符串的有效性。我宁愿保持超时

低。这样做的传统方式是什么?
I''d like to include a ''Test Connection'' button in an app, for testing
validity of a SQL connection string. I''d prefer to keep the timeout
low. What is the conventional way of doing this?





" _DD" < _D*@nospam.com写在留言中

新闻:15 ***************************** *** @ 4ax.com ...

|我想在应用程序中包含一个测试连接按钮,用于测试

| SQL连接字符串的有效性。我宁愿保持超时

|低。这样做的常规方法是什么?


将连接字符串中的超时值(连接超时)设置为

所需的值和问题一个SqlConnect.Open。这是测试

的唯一方法,连接字符串是否有效且服务器是否接受

连接。


Willy 。



"_DD" <_D*@nospam.comwrote in message
news:15********************************@4ax.com...
| I''d like to include a ''Test Connection'' button in an app, for testing
| validity of a SQL connection string. I''d prefer to keep the timeout
| low. What is the conventional way of doing this?

Set the timeout value ("Connect Timeout") in the connection string to the
desired value and issue a SqlConnect.Open. This is the only way to test
whether a Connection string is valid AND the server is accepting the
connection.

Willy.



这篇关于确定SQL Server是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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