且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在与LAN连接的其他计算机上使用SQL Server数据库运行桌面应用程序

更新时间:2022-12-24 10:32:33

默认情况下,SQL Server Express中的远程连接已关闭.

By default Remote connections in SQL Server Express is turned off.

只需打开SQL Express的远程连接,启用TCPIP协议并重新启动服务,检查errorlog是否正在所有网络适配器上进行侦听现在尝试使用客户端PC上的计算机名称(因为它是动态的)进行连接

Just turn on the remote connections for SQL Express, enable TCPIP protocal and restart the service, check errorlog whether it's listening on all network adapters Now try to connect using the machine name (since it's dynamic) from the client pc

这是一个步骤

  • 打开SQL Server配置管理器
  • 选择SQL Server网络配置
  • 选择您的SQL Server实例
  • 确保已启用TCP/IP协议
  • 右键单击TCP/IP协议
  • 选择属性
  • 单击"IP地址"标签
  • 向下滚动到IP4.服务器的IP地址应该在这里.将活动设置为是,将其设置为是.将TCP端口设置为1433(不知道这是否有必要.可以征询专家的意见)
  • 向下滚动到IPAll.将TCP端口设置为1433
  • 为端口1433制定入站防火墙规则
  • 打开sql服务器管理工​​作室,右键单击服务器实例,然后单击属性"->连接"->允许远程连接".安全性-> SQL Server和Windows身份验证模式
  • 重新启动sql服务器服务
  • 重新启动sql server浏览器

现在使用sql连接字符串 COMPUTERNAME 例如

now use sql connection string COMPUTERNAME for E.g

data source=COMPUTERNAME;database=databasename;user id=sa;password=pass;" providerName="System.Data.SqlClient"

另一个参考链接.. http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx

Another reference link ..http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx