请帮助我获取“服务器"和“数据源"在字符串连接的SQL连接? [英] Please help me on obtaining "server" and "data source" in string connection for sql connection?

查看:130
本文介绍了请帮助我获取“服务器"和“数据源"在字符串连接的SQL连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的好友:

我有一个sql db及其应用程序.我将此程序和关联的sql数据库带到另一台计算机.如何在sql连接中获取用于字符串连接的新计算机的服务器"和数据源"?我应该提到我没有任何信息.关于来宾计算机,并假定来宾计算机没有任何sql managemnt系统,因此我的应用程序应获取服务器"和数据源"才能正常工作.


Yours

Dear Buddies:

I have a sql db with its application. I bring this program and the associated sql database to another computer. How can I get the "server" and "data source" of new computer for string connection in sql connection? I should mention that I do not have any info. about the guest computer and assume that the guest computer does not have any sql managemnt system, so my application should obtain the "server" and "data source" to work properly.


Yours

推荐答案

访问 SQL Server 2008的连接字符串 [< ^ ]

解析服务器名称和实例的一种不错的方法是打开Sql Server Management Studio,连接到数据库,然后在属性框中,您应该看到服务器名称和实例.

加法:

当前到本地Sql Server数据库的连接字符串示例:
Visit Connection strings for SQL Server 2008[^]

Also one nice way to resolve server name and instance is to open Sql Server Management Studio, connect to the database and then in the properties box, you should see the server name and instance.

Addition:

Example of current connection string to a local Sql Server database:
Server=(local)\MyInstance;Database=TestDatabase;Trusted_Connection=True;



客户端用于连接到单个Sql Server数据库的连接字符串示例:



Example of a connection string that clients use to connect to a single Sql Server database:

Server=ServerXYZ\TheInstanceName;Database=ProductionDatabase;Trusted_Connection=True;


对于Web应用程序:
Data Source = .\.; integrated Security= true; Database=yourdatabasename;



对于Windows应用程序:



For Windows Application :

Data Source=.\\.; integrated Security= true; Database=yourdatabasename;



现在代替服务器或数据源的第一个.可以理解为默认SQL Server,第二个.代表默认实例.



Now in place of Server or Datasource first . works understood Default SQL Server and Second . stand Default Instance.


这篇关于请帮助我获取“服务器"和“数据源"在字符串连接的SQL连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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