SQL网络接口,错误:26 - 错误定位指定的MDF文件服务器/实例 [英] SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified for MDF file

查看:343
本文介绍了SQL网络接口,错误:26 - 错误定位指定的MDF文件服务器/实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Visual Studio内置功能增加了一个数据库文件(密度纤维板),以我的应用程序。数据库是在的App_Data 文件夹中。它运行良好。但是,当我发布并上传到服务器时,它给出了这样的错误。

I have added a database file (.mdf) to my application using Visual Studio built-in functionality. Database is in the App_Data folder. It is running fine. But when I publish it and upload it to server it gives this error.

发生-特定实例的网络相关的或错误而
  与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)

我参观了类似的情况,但困惑。我不知道哪个版本和SQL Server版的服务器正在运行。我上传的项目使用Filezilla。我的连接字符串是在我的的web.config如下

I visited similar situation but confused. I don't know which version and edition of SQL Server is running at server. I upload project using Filezilla. My connection string is as follows in my web.config:

<add name="ConnectionString" 
     connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" 
     providerName="System.Data.SqlClient"/>

请描述流程一步一步是可能的。

Please describe process step by step is possible.

先谢谢了。

推荐答案

整个的用户实例和AttachDbFileName = 的方法是有缺陷的 - 在最好的!此外,它只有在防爆preSS支持 SQL Server的版本 - 所以,如果你的主机托管服务提供商比前preS ,你基本上拧其他任何

The whole User Instance and AttachDbFileName= approach is flawed - at best! Also, it's only supported by the Express edition of SQL Server - so if your hoster has anything other than Expres, you're basically screwed.

真正的解决方案在我看来,将


  1. 安装SQL Server Management Studio中前preSS

  1. install SQL Server Management Studio Express

在数据库中创建的 SSMS防爆preSS ,给它一个合理的名称(如 MyDatabase的

create your database in SSMS Express, give it a logical name (e.g. MyDatabase)

连接使用其逻辑的数据库名称为(当你在服务器上创建它交给) - 和周围不乱用物理数据库文件和用户实例。在这种情况下,您的连接字符串会是这样:

connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:

Data Source=.\\SQLEXPRESS;Database=MyDatabase;Integrated Security=True

和其他一切都是究竟和以前一样...

and everything else is exactly the same as before...

现在,当你去,并上传你的网站托管网站,你需要获得必要的SQL脚本来创建和托管网站填充数据库 - 您可以使用任务做到这一点&GT;生成脚本从SSMS防爆preSS工具,或通过其他方式。

Now, when you go and upload your web site to the hosting site, you need to get the necessary SQL scripts to create and populate your database on the hosting site - you can do this by using Tasks > Generate Scripts from the SSMS Express tool, or by some other means.

然后,在托管网站,您需要执行这些SQL脚本来创建和填充数据库(以及后来的:执行修改脚本来保持数据库最新)

Then, on the hosting site, you need to execute those SQL scripts to create and populate your database (and later on: execute the change scripts to keep the database up to date).

您的连接字符串也将极有可能改变这样的:

Your connection string will also most likely change to something like:

Server=(ip-address-or-name);Database=MyDatabase;User ID=YourUserIdHere;Pwd=YourPassword

由于托管服务提供商不使用 SQLEX $ P $干燥综合征命名实例(但最有可能是默认实例没有任何名称) 。你需要问你的供应商的细节 - 这可能是因为你必须提供其它一些实例名称!这完全取决于供应商,我们无法知道 - 你要问,找出

since the hosting provider doesn't use the SQLEXPRESS named instance (but most likely a default instance without any name). You need to ask your provider for the details - it could be that you have to provide some other instance name! That's totally up to the provider, we cannot know that - you'll have to ask and find out.

这篇关于SQL网络接口,错误:26 - 错误定位指定的MDF文件服务器/实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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