使用ADO.net使用ASP.NET MVC创建注册页面

时间:2017-08-15 06:46:00

标签: asp.net-mvc ado.net

嘿,我通过使用ADO.net或企业库,使用asp.net MVC创建了注册页面。 我不想使用实体框架。

我的数据库结构是

    CREATE table Registration (
CustomerId int IDENTITY(1,1) NOT NULL Primary key,
Name varchar(255) NOT NULL,
ContactNo varchar(255) NOT NULL,
EmailId varchar(255) NOT NULL,
Address varchar(255) NOT NULL,
Dob varchar(255) NOT NULL,

);

我在类库中创建了该方法

我的模型文件是

 public string Name { get; set; }
    public string ContactNo { get; set; }
    public string EmailId { get; set; }
    public string Address { get; set; }
    public string Dob { get; set; }

我在控制器中编写什么代码来获取数据库中cutomer的值

1 个答案:

答案 0 :(得分:1)

参考this link

  

我在控制器中编写什么代码来获取数据库中cutomer的值

您需要创建controllerviews来将数据存储到数据库。我认为您是MVC的新用户,因为MVC本身代表Model View Controller

您已创建模型。

public string Name { get; set; }
public string ContactNo { get; set; }
public string EmailId { get; set; }
public string Address { get; set; }
public string Dob { get; set; }

但您错过了primary key CustomerId,如果没有这个,您将无法访问相应的表格。

请参阅this site了解更多信息。