Populate asp.net MVC Index page with data from the database
- by Sunil Ramu
I have a web application in which I need to fetch data from the database and display in the index page. As you know, asp.net mvc has given options to edit delete etc...
I need to populate the page using the conventional DB way and it uses a stored procedure to retrieve results. I dont want to use LINQ.
This is my model entity class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LogMVCApp.Models
{
public class Property
{
public int Id { get; set; }
public string LogInId { get; set; }
public string Username { get; set; }
public string Action { get; set; }
public string Information { get; set; }
public bool Passed{get; set; }
public string LogType { get; set; }
}
}
and I need to retrieve data using something like this...
var conString = ConfigurationManager.ConnectionStrings["connection"].ToString();
var conn = new SqlConnection(conString);
var command = new SqlCommand("LogInsert", conn){CommandType=CommandType.StoredProcedure};