Connection
-
using MvcPagingApp.Models; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; namespace MvcPagingApp { public class Connection { //public DataSet mydata() //{ // SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Mycon"].ToString()); // SqlCommand cmd = new SqlCommand("select * from TblEmployeeDetails", con); // cmd.CommandType = CommandType.Text; // SqlDataAdapter da = new SqlDataAdapter(); // da.SelectCommand = cmd; // DataSet myrec = new DataSet(); // da.Fill(myrec); // return myrec; //} public IEnumerable Department { get { string connectionString = ConfigurationManager.ConnectionStrings["Mycon"].ConnectionString; List department = new List(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("select * from DeptTable", con); // cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Department employee = new Department(); employee.DeptID = rdr["DeptID"].ToString(); employee.DeptName = rdr["DeptName"].ToString(); department.Add(employee); } } return department; } } public IEnumerable Employees { get { string connectionString = ConfigurationManager.ConnectionStrings["Mycon"].ConnectionString; List employees = new List(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("spEmployee", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Employee employee = new Emplo
-
using MvcPagingApp.Models; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; namespace MvcPagingApp { public class Connection { //public DataSet mydata() //{ // SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Mycon"].ToString()); // SqlCommand cmd = new SqlCommand("select * from TblEmployeeDetails", con); // cmd.CommandType = CommandType.Text; // SqlDataAdapter da = new SqlDataAdapter(); // da.SelectCommand = cmd; // DataSet myrec = new DataSet(); // da.Fill(myrec); // return myrec; //} public IEnumerable Department { get { string connectionString = ConfigurationManager.ConnectionStrings["Mycon"].ConnectionString; List department = new List(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("select * from DeptTable", con); // cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Department employee = new Department(); employee.DeptID = rdr["DeptID"].ToString(); employee.DeptName = rdr["DeptName"].ToString(); department.Add(employee); } } return department; } } public IEnumerable Employees { get { string connectionString = ConfigurationManager.ConnectionStrings["Mycon"].ConnectionString; List employees = new List(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("spEmployee", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Employee employee = new Emplo