如何连接另一台机器的SQL数据库 [英] How to connect with another machines SQL database

查看:106
本文介绍了如何连接另一台机器的SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有两个计算机com1和com2这两个正在用共享数据库开发应用程序。并且数据库存在于com1中。我想在com2中使用一些数据库。实际上我需要做什么,这就是为什么我能用com1连接。



我尝试了什么:



我需要使用局域网或广域网进行所有这一过程。

请帮帮我

解决方案

只需从COM2打开SSMS并输入COM1 \SQLEXPRESS作为serverName



尝试连接它。如果您发现任何问题,请参阅

MSDN帮助 [ ^ ]


这是SQL Server你使用 SqlConnection类(System.Data.SqlClient) [ ^ ]建立与SQL Server的连接,该SQL Server可能驻留在您的计算机上或网络中的其他位置。该位置在 SqlConnection.ConnectionString属性中指定(System.Data.SqlClient) [ ^ ]并且它可能最容易使用 SqlConnectionStringBuilder类(System.Data.SqlClient) [ ^ ]构建连接字符串。



对于其他一些原则,请查看正确执行数据库操作 [ ^ ]


一个Sql server实例有为LAN / WAN上的每台机器可见。要实现这一点,您必须启用远程连接 [ ^ ] com1 machine。请参阅:

配置服务器以侦听特定TCP端口(SQL Server配置经理) [ ^ ]

配置服务器以在备用管道上侦听(SQL Server配置管理器) [ ^ ]



现在,您必须编写正确的连接字符串 [ ^ ]。



请注意,有时您必须配置Windows防火墙以允许SQL Server访问 [< a href =https://msdn.microsoft.com/ en-us / library / cc646023.aspxtarget =_ blanktitle =New Window> ^ ]



祝你好运!

hello i have two computer com1 and com2 both this are developing the application with shared database. and the database is present in com1. i want to use the some database in com2. what actually i need to do thats why i can able to connect with com1.

What I have tried:

all this process i need to do using LAN or WAN network.
please help me

解决方案

Just open SSMS from COM2 and key in "COM1\SQLEXPRESS" as serverName

Try connecting it. if you see any problems refer
MSDN HELP[^]


Taken this is SQL Server you use a SqlConnection Class (System.Data.SqlClient)[^] to establish a connection to a SQL Server which may reside on your computer or somewhere else in the network. The location is specified in SqlConnection.ConnectionString Property (System.Data.SqlClient)[^] and it's probably easiest to use SqlConnectionStringBuilder Class (System.Data.SqlClient)[^] to build the connection string.

For some further principles, have a look at Properly executing database operations[^]


An Sql server instance have to be "visible" for each machine on LAN/WAN. To achieve that you have to enable remote connections[^] for com1 machine. See:
Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager)[^]
Configure a Server to Listen on an Alternate Pipe (SQL Server Configuration Manager)[^]

Now, you have to write proper connection string[^].

Note that sometimes you have to Configure the Windows Firewall to Allow SQL Server Access[^]

Good luck!


这篇关于如何连接另一台机器的SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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