where is data stored?
name
and fname
(father name).
my controller class:
loginController.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcMovie.Models;
namespace MvcMovie.Controllers
{
public class loginController : Controller
{
private logindata db = new logindata();
//
// GET: /login/
public ViewResult Index()
{
return View(db.loginobj.ToList());
}
//
// GET: /login/Details/5
public ViewResult Details(int id)
{
// login login = db.loginobj.Find(id);
login login = db.loginobj.Find(2) ;
return View(login);
}
//
// GET: /login/Create
public ActionResult Create()
{
return View();
}
//
// POST: /login/Create
[HttpPost]
public ActionResult Create(login login)
{
if (ModelState.IsValid)
{
db.loginobj.Add(login);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(login);
}
//
// GET: /login/Edit/5
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
model class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
login.cs
namespace MvcMovie.Models
{
public class login
{
public int ID { get; set; }
public string name{get; set;}
public string fname { get; set; }
}
public class logindata : DbContext
{
public DbSet<login> loginobj { get; set; }
}
}
view.cshtml
@model IEnumerable<MvcMovie.Models.login>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
name
</th>
<th>
fname
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.fname)
</td>
<td>
@Html.ActionLink("Edit&开发者_高级运维quot;, "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
</table>
I want to ask that where is data stored which is created by me? means how can I see that table of entries which is done by me?
whenever i click of .sdf file then there is a problem occured as shown in following picture, what should i do to solve this problem. should i installed something. i installed visual studio 2010 and sql server 2008.
Probably you're using Microsoft SQL CE to store your application data. If this is the case, take a look at the App_Data folder in Solution Explorer. You should see a file with .sdf extension there. Just make sure to select Show All Files icon in Solution Explorer. More details here.
You will need to install Visual Studio SP1, because the tutorial you are running is thinking you are using Visual Studio Express.
You can get it here:
http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=VS2010SP1Pack
it looks like its done through
private logindata db = new logindata();
Do you have that part in details?
That logindata DBContext looks like it was created by Entity Framework. That's pointing to a database somewhere, and that database is where you'd go to find your data. You could look in web.config for a connection string that has the database info, or if your project has a .edmx file in it open that and see what its pointing at.
精彩评论