如何通过局域网连接sql server数据库 [英] How to connect to sql server database via LAN

查看:70
本文介绍了如何通过局域网连接sql server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要连接到另一台通过 LAN 连接的 PC 上的数据库.我可以使用带有 C:\Users... 这样的字符串的 sql server db,但我无法使用像 (\\Server\c\user...) 这样的字符串连接我试图将 db 文件移动到我的文档,但仍然我收到这个错误.

want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.

我收到以下错误消息:尝试为文件 (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) 附加自动名称数据库失败.存在同名数据库,或无法打开指定文件,或位于 UNC 共享上

I get the following error message: An attempt to attach an auto-names database for file (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share

我希望我问对了问题

推荐答案

由于数据库不支持 '\SERVER\c...' 参数,我不得不附加数据库,启用 TCP/IP 和 SQL 浏览器后,我必须通过安全性创建登录并将其添加到附加的数据库文件中,因为身份验证必须是 SQL 而不是 Windows.而且我还授予了该帐户的读/写权限.然后在子系统上,我通过 SSMS 确认连接到帐户,登录名连接到 SERVER(这是远程计算机的名称).

As database does not support the '\SERVER\c...' parameters, i had to attach the database, after enabling TCP/IP and SQL Browser, i had to create a login through security and add it to the attached database file because authentication must be SQL not windows. And i also gave read/write privileges to the account. Then on the child system, i confirmed connection to the account through SSMS with the login connecting to SERVER (which is the remote computer's name).

注意:您必须能够ping 远程系统和安装的SQL Server Express R2.我尝试使用 SQL Server Express,但没有取得进展.www.connectionstrings.com/sql-server-2008 获取更多连接字符串

Note: you must be able to ping the remote systems and SQL Server Express R2 installed. I tried with SQL Server Express but did not get a head way. www.connectionstrings.com/sql-server-2008 for more connection string

然后我使用此连接字符串进行远程连接,使集成安全性和用户实例 = false 与本地连接不同.

Then i used this connection string to connect remotely, making integrated security and user instance = false unlike if i were connecting locally.

 Data Source=SERVER\SQLEXPRESS,1433;Database=DATABASEFILE.MDF;Integrated Security=False;Network Library=dbmssocn;Connect Timeout=30;User Instance=False;user='USERNAME';password='PASSWORD'

这篇关于如何通过局域网连接sql server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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