c# - ASP.NET MVC : problem connecting to a database

标签 c# asp.net-mvc-3

我正在使用这个指南: http://www.asp.net/mvc/tutorials/mvc-music-store-part-7

按照说明,我进入了 ASP.NET Web Application Administrator,但是当我进入安全选项卡时:

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

我确实点击了下面的按钮,但一点帮助也没有。

到目前为止,我完全(我认为..)按照指南所说的那样做了。 我有一种可怕的感觉,答案是显而易见的。

编辑 1: 顺便说一句,当我打开指南中的完整解决方案并尝试打开 ASP.NET Web Application Administrator 时,出现以下错误:

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: 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)

编辑 2: 连接字符串:

<connectionStrings>
    <add name="MusicStoreEntities"
     connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
     providerName="System.Data.SqlServerCe.4.0"/>
  </connectionStrings>

最佳答案

您是否安装了 SQL Server Express 并且您在 app_data 中有数据库?

关于c# - ASP.NET MVC : problem connecting to a database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5999851/

相关文章:

c# - ASP Net MVC - 验证消息的本地化

c# - 在 C# .NET 控制台应用程序中使用 OCX 控件

asp.net-mvc - jQuery.parseJSON 不适用于 MVC Controller 操作中的 JsonResult

c# - 使用 Entity Framework Code First 版本 5 中的 SQL View

c# - 使用控制部件或视觉状态管理器,或两者都使用?

c# - MonoTouch 中的 UISaveVideoAtPathToSavedPhotosAlbum 在哪里?

c# - 针对 MySQL 同时使用 MVC 应用程序和 MS Access 时记录被覆盖

c# - MVC 3 级联下拉列表

forms - @ Html.ValidationMessageFor()自定义validationMessage始终显示

asp.net-mvc-3 - 如何使用asp.net mvc3 和c# 构建网络爬虫?