- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发一个笑话网络应用程序。
我使用 C#、Entity Framework、MVC,并且代码优先。
现在,当我尝试读取我的数据库中的内容时,出现了我在标题中输入的错误。我不知道要寻找什么。我查了谷歌,但没有得到答案...
我尝试提供您可能需要知道的所有代码:
public class Context : DbContext
{
public DbSet<Categorie> Categories {get;set;}
public Context() : base("Witze_DB")
{
}
}
public class HomeController : Controller
{
private Context db;
public HomeController(Context db)
{
this.db = db;
}
public ActionResult Index()
{
var allCats = db.Categories;
return View(allCats);
}
}
这是 Index.cshtml
文件:
@model IEnumerable<Witze.Categorie>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CategorieId }) |
@Html.ActionLink("Details", "Details", new { id=item.CategorieId }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CategorieId })
</td>
</tr>
}
</table>
这就是我得到的回复:(它会更长,如果它确实对你有帮助,我也会发布其余部分,它只是更多 System.Data.SqlClient
...)
Server Error in '/' Application.
--------------------------------------------------------------------------------
The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
Line 18: </tr>
Line 19:
Line 20: @foreach (var item in Model) {
Line 21: <tr>
Line 22: <td>
Source File: c:\Users\a80815067.EISLAB\Documents\Visual Studio 2012\Projects\Witze_Logik\Witze_Web\Views\Home\Index.cshtml Line: 20
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5295887
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242
如果您需要任何其他信息,请询问。
最佳答案
查看堆栈跟踪,您有以下错误:
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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.
很可能是您的连接字符串无效。
关于c# - [Win32Exception (0x80004005) : The system cannot find the file specified],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21730294/
我是一名优秀的程序员,十分优秀!