Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. Connection

Connection

Scheduled Pinned Locked Moved - Uncategorised posts -
csharplinqworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11683062
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups