无法使用连接字符串 .\\Sqlexpress 连接应用程序 [英] Cant connect application with connection string .\\Sqlexpress

查看:28
本文介绍了无法使用连接字符串 .\\Sqlexpress 连接应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者,使用 mircosoft Sql Server 2005.我连接服务器名称:Windows 身份验证上的 USER-PC.现在这在我的 Windows 应用程序中造成了一个严重的问题.我想在我的应用程序的连接字符串中使用 .\SQLEXPRESS 但这样做会产生一个错误说:

i am a beginner and using mircosoft Sql Server 2005. i connect with Server name : USER-PC on Windows Authentication. now this is creating a serious problem in my Windows Application. i want to use .\SQLEXPRESS in the connection string in my application but doing this creates an error saying:

与 SQL Server 建立连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接.(提供程序:SQL 网络接口,错误:26 - 错误定位服务器/指定的实例)

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

我尝试了很多来解决问题,但找不到解决方案.我使用的连接字符串是:

m trying a lot to solve the problem but cant find the solution. the connection string i used is:

SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=demo; Integrated Security=true");

请提供我的问题的解决方案或链接.

please provide solution or link to my problem.

推荐答案

.\SQLEXPRESS 表示您有名为 localhost\SQLEXPRESS 的 SQL Express 本地实例.如果您尝试访问服务器 USER-PC 上的数据库,请使用 Data Source=USER-PC 之类的方法,或者如果您有 SQLEXPRESS 的命名实例,请使用 数据源=USER-PC\\SQLExpress

.\SQLEXPRESS means that you have local instance of SQL Express named as localhost\SQLEXPRESS. If you are trying to access database on server USER-PC then use that like Data Source=USER-PC or if you have a named instance of SQLEXPRESS then use Data Source=USER-PC\\SQLExpress

这篇关于无法使用连接字符串 .\\Sqlexpress 连接应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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