SQL Server Express的连接字符串出错

本文关键字:字符串 出错 连接 Server Express SQL | 更新日期: 2023-09-27 18:19:02

我开发了一个软件来提醒我的客户他将来想做什么。

我可以在我自己的笔记本电脑上使用它,但是当我创建一个安装文件并安装在客户的笔记本电脑上时,它有一些错误。当我在我自己的笔记本电脑上使用这个软件时,我的连接字符串是

server=localhost;database=Reminderdatabase;Trusted_Connection=true;

,当我想在客户笔记本电脑中使用它时,我使用这个连接字符串

@"Data Source=.'SQLEXPRESS;AttachDbFilename=|DataDirectory|'ReminderDatabase.mdf;Integrated Security=True;user instance=true;
我在他的笔记本电脑上安装了SQL Server 2008 R2和。net framework 4.0。

现在当我想连接数据库时出现了一个错误,说

在建立到SQL Server的连接时发生与网络相关或特定实例的错误。未找到服务器或无法访问服务器。验证实例名是否正确,SQL Server是否配置为允许远程连接。(provider: SQL Network Interfaces, error 26 - error location Server/Instance Specified).

这让我很困惑。我在50多个链接中寻找它,但它给我的答案并不好。我没有更多的时间去学习和搜索用户实例或类似的东西,并理解它。请告诉我如何解决这个错误。

非常感谢您的帮助

SQL Server Express的连接字符串出错

try with this

 @"Data Source=.''SQLEXPRESS;AttachDbFilename=|DataDirectory|''ReminderDatabase.mdf;Integrated Security=True;user instance=true;

服务器端:

Make sure that you have enabled remote connections on the instance (RELYONDB) of SQL Server.
Make sure that firewall is OFF.
Make sure that firewall has been configured to make an exception for SQLBROWSER.EXE and SQLSERVR.EXE in server computer.

客户端:

Make sure that you have typed correct server computer name and instance name
Make sure that server machine is reachable. Check you are able to ping the server.
Make sure that you are able to access the shared folder of remote server.
Make sure that you are able to connect SQL Server using the Telnet command.

解决方案1:

同时启用TCP/IP和命名管道:

所有程序| Microsoft SQL Server 2005|配置工具| SQL Server表面积配置|服务和连接配置|远程连接,选择本地和远程连接|启用同时使用TCP/IP和命名管道

重启SQL Server RELYONDB &SQL Server浏览器服务。

解决方案2:

同时启用TCP/IP和命名管道:

所有程序| Microsoft SQL Server 2005|配置工具| SQL Server配置管理器| SQL Server网络配置|右键单击"命名管道"&点击启用>右键点击" TCP'IP " &点击启用

重启SQL Server RELYONDB和SQL Server Browser服务

解决方案3:

单击Start | Run | type firewall。cpl | Switch Off |点击OK

在windows防火墙中创建一个例外

将TCP端口或sqlservr.exe添加到防火墙例外列表中,添加" .'Binn' sqlservr.exe "或添加端口。

将Sql Browser服务添加到防火墙例外列表中,您可以添加程序" C:'Program Files'Microsoft Sql Server'90'Shared'sqlbrowser.exe "或添加UDP端口1434

解决方案4:[客户端]

检查客户端和服务器系统是否都在ping通

点击开始|运行|键入cmd|点击确定

以管理员身份运行打开命令提示符|键入PING

解决方法5:[客户端] 解析DNS缓存:

点击开始|运行|键入cmd|点击确定

以管理员身份打开命令提示符| type ipconfig/flushdns

解决方案6:[客户端]

在连接字符串中给出服务器IP地址而不是主机名