简体   繁体   English

SQL Server Express的连接字符串错误

[英]Error with connection string for SQL Server Express

I have developed a software for remind for my costumer what he want to do in future. 我开发了一个软件来提醒我的客户将来他想做什么。

I can use it in my own laptop but when I create a setup file and install it in customer laptop it has some errors. 我可以在自己的笔记本电脑中使用它,但是当我创建安装文件并将其安装在客户笔记本电脑中时,它会出现一些错误。 when i use this software in my own laptop my connection string is 当我在自己的笔记本电脑上使用此软件时,我的连接字符串为

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

and when I want to use it in customer laptop I use this connection string 当我想在客户笔记本电脑中使用它时,我使用此连接字符串

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

and I installed SQL Server 2008 R2 on his laptop and .net framework 4.0. 我在他的笔记本电脑和.net Framework 4.0上安装了SQL Server 2008 R2。

Now when I want to connect to database an error occurred that say a 现在,当我要连接到数据库时,发生了一个错误,说

network-related or instance-specific error occurred while establishing a connection to SQL Server. 建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 verify that instance name is correct and SQL Server is configured to allow remote connections.(provider: SQL Network Interfaces, error 26 - Error Locating Server/Instance Specified). 验证实例名称正确,并且将SQL Server配置为允许远程连接。(提供者:SQL网络接口,错误26-错误指定服务器/实例的位置)。

This confused me. 这让我感到困惑。 I looked for it in more than 50 links but not good answer it gave to me. 我在50多个链接中寻找它,但它给我的答案不是很好。 I do not have more time to learn and search for user instance or things like that and understand it. 我没有更多的时间来学习和搜索用户实例或类似的东西并理解它。 Please tell me what I must do to solve this error. 请告诉我该如何解决此错误。

Thank you so much for your helping 非常感谢您的帮助

试试这个

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

Server side: 服务器端:

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.

Client side: 客户端:

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.

Workaround 1: 解决方法1:

Enable Using both TCP/IP and Named Pipes: 启用同时使用TCP / IP和命名管道:

All programs | 所有程序| Microsoft SQL Server 2005| Microsoft SQL Server 2005 | Configuration Tools | 配置工具| SQL Server Surface Area Configuration | SQL Server外围应用配置器| Configuration for Services and Connections | 服务和连接的配置| Remote Connections, choose Local and Remote Connections |Enable Using both TCP/IP and Named Pipes. 在“远程连接”中,选择“本地和远程连接|启用同时使用TCP / IP和命名管道”。

Restart SQL Server RELYONDB & SQL Server Browser service. 重新启动SQL Server RELYONDB和SQL Server浏览器服务。

Workaround 2: 解决方法2:

Enable Using both TCP/IP and Named Pipes: 启用同时使用TCP / IP和命名管道:

All programs | 所有程序| Microsoft SQL Server 2005| Microsoft SQL Server 2005 | Configuration Tools | 配置工具| SQL Server Configuration Manager| SQL Server配置管理器| SQL Server Network configuration| SQL Server网络配置| Right Click “Named Pipes” & Click Enable > Right Click “TCP\\IP” & Click Enable 右键单击“命名管道”并单击启用>右键单击“ TCP \\ IP”并单击启用

Restart SQL Server RELYONDB and SQL Server Browser service. 重新启动SQL Server RELYONDB和SQL Server浏览器服务。

Workaround 3: 解决方法3:

Click Start | 单击开始| Run | 运行 type firewall.cpl | 键入firewall.cpl | Switch Off | 关闭| Click OK. 单击确定。

or 要么

Create an exception in windows firewall. 在Windows防火墙中创建例外。

Add TCP port or sqlservr.exe to Firewall exception list, either add “..\\Binn\\sqlsevr.exe” or add port. 将TCP端口或sqlservr.exe添加到防火墙例外列表中,或者添加“ .. \\ Binn \\ sqlsevr.exe”或添加端口。

Add Sql Browser service to Firewall exception list, you can either add program ” C:\\Program Files\\Microsoft SQL Server\\90\\Shared\\sqlbrowser.exe” or add UDP port 1434 将Sql Browser服务添加到防火墙例外列表中,您可以添加程序“ C:\\ Program Files \\ Microsoft SQL Server \\ 90 \\ Shared \\ sqlbrowser.exe”或添加UDP端口1434

Workaround 4: [Client side] 解决方法4:[客户端]

Check whether PINGing is happening in both client and server systems 检查客户端和服务器系统中是否都在执行Ping操作

Click Start | 单击开始| Run | 运行 type cmd| 输入cmd | Click OK 点击确定

Open command prompt as Run as Administrator | 以“以管理员身份运行”打开命令提示符| Type PING PING类型

Workaround 5: [Client side] 解决方法5:[客户端]

Resolve DNS cache: 解决DNS缓存:

Click Start | 单击开始| Run | 运行 type cmd| 输入cmd | Click OK 点击确定

Open command prompt as Run as Administrator | 以“以管理员身份运行”打开命令提示符| type ipconfig /flushdns 输入ipconfig / flushdns

Workaround 6: [Client side] 解决方法6:[客户端]

Give server IP address in connection string instead of hostname. 在连接字符串而不是主机名中提供服务器IP地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM