连接字符串错误(错误:40) [英] Connection String Error (error : 40)

查看:93
本文介绍了连接字符串错误(错误:40)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在Windows Server 2008计算机上安装了SQL Server 2012 Express。机器的名称是 THEMACHINE。安装时,我将SQL Server 2012设置为默认实例。
现在,我将连接字符串设置如下:

I have installed SQL Server 2012 Express on a Windows Server 2008 Machine. The name of the machine is "THEMACHINE". While installation, I set SQL Server 2012 as "Default Instance". Now I set my connection string like this :

<add name="BooksContext" providerName="System.Data.SqlClient" connectionString="Data Source=THEMACHINE;Initial Catalog=newdb; User ID=sa; Password=123456"/>

但是我得到了这个例外:

But I get this exception :


{
建立与SQL Server的连接时发生了与网络有关或特定于实例的错误。找不到服务器或无法访问
。请验证实例名称是正确的,并且
SQL Server已配置为允许远程连接。(提供者:名为
Pipes Provider,错误:40-无法打开与SQL
Server的连接)}

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}

我检查了数据库是否正在运行。谢谢。

I checked that database is running. Can you tell me what I'm doing wrong?Thanks.

推荐答案

参考: 创建和配置通用数据链接(.udl)文件

执行以下操作以建立测试连接生成连接字符串,

Do following to Test connection and generate connection string,

1)在桌面上创建 query.udl 文件

1) Create query.udl file in the desktop

2)双击文件以打开并执行以下操作

2) Double click the file to open and do the following

3)在记事本中打开 Query.udl ,您将找到连接字符串

3)Open the Query.udl in notepad, you will find the connectionstring.

这篇关于连接字符串错误(错误:40)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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