其中,在数据存储? [英] where is data stored?

查看:99
本文介绍了其中,在数据存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MVC3设计一个项目在.NET 4.0中。我使用的这两个属性名称 FNAME (父亲姓名)。

我的控制器类:

loginController.cs

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);
        }
    }
}

模型类

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

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", "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?

每当我点击.sdf文件中则存在发生如以下的画面有问题,我应该怎么做才能解决这个问题。我应该安装什么东西。我安装了Visual Studio 2010和SQL Server 2008。

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.

推荐答案

也许你使用的是Microsoft SQL CE存储应用程序数据。如果是这样的话,就来看看在Solution Explorer中的App_Data文件夹。您应该看到。自卫队扩展有一个文件。只需确保在解决方案资源管理器中选择显示所有文件图标。更多细节这里

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.

这篇关于其中,在数据存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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