我如何在不提供ConnectionString的情况下检索SQL的服务器名称 [英] how do i retrieve a server name of SQL without providing ConnectionString

查看:66
本文介绍了我如何在不提供ConnectionString的情况下检索SQL的服务器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Connectionstring ...成功地尝试使用C#和ADO.NET连接建立与sql表的连接. 但是我希望该应用程序自动检索serverName ... bcoz aftr发布该应用程序将无法在另一台计算机上工作. 没有该SQL Server的服务器名称....
请帮助/////.....

imtrying toestablish a connection with sql tables using C# and ADO.NET connection is done successfully using Connectionstring....
but i want that application to retrieve a serverName automatically... bcoz aftr publishing that application wont work on another machine..
without the servername of that SQL Server....
please help/////.....

推荐答案

可能有多种方法可以使用代码对SQL Server进行迭代.但是,如果最终用户要部署自己的SQL Server实例,我希望他们随后必须在应用程序的首选项中设置其查询字符串.如果有多个可见的SQL Server实例怎么办?如果他们两个都有正确名称的数据库怎么办?唯一合乎逻辑的事情是让用户控制它,而不是试图为他们自动完成.
There are probably ways to iterate over SQL Servers using code. However, if your end user is going to deploy their own SQL Server instance, I would expect they would then have to set their query string in the preferences for your application. What if there''s more than one SQL Server instance visible ? What if they both have a DB with the right name ? The only logical thing to do, is let the user control it, not to try to automagically do it for them.


这篇关于我如何在不提供ConnectionString的情况下检索SQL的服务器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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