Populate asp.net MVC Index page with data from the database
Posted
by Sunil Ramu
on Stack Overflow
See other posts from Stack Overflow
or by Sunil Ramu
Published on 2010-06-11T11:37:01Z
Indexed on
2010/06/11
11:42 UTC
Read the original article
Hit count: 258
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};
© Stack Overflow or respective owner