我是一名初学者,一般使用C#和MVC,我一直在关注MVC Music Store tutorial,因为我的任务问题类似于教程(它是一个商店)。但是,我遇到了一个问题。我需要将SQL Server Express用于数据库而不是SQL Server Compact。MVC 3 - 使用SQL Server Express
我改变了连接字符串,当它编译它不工作..
<add name="FashionStyle" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|FashionStyle.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
在我StoreController
:
public ActionResult Index()
{
var types = storeDB.Types.ToList();
return View(types);
}
查看:
<h3>Browse Type of Product</h3>
<p>
Select from @Model.Count() type:</p>
<ul>
@foreach (var type in Model)
{
<li>@Html.ActionLink(type.Name, "Browse", new { type = type.Name })</li>
}
</ul>
此外,当我运行并导航到商店页面,显示“浏览产品类型从0类型中选择:”。我还使用了教程中的修改sampledata.cs
我们不能看到你改变了连接字符串,请确保您已经安装了SQL Express和连接字符串正确地反映了你的sql express实例所在的位置。你可以在http://www.connectionstrings.com找到连接字符串的更多细节。 –
你是否收到错误?你能否定义“它不工作”是什么意思? –
erm原来它使用 –
Edwin