Schleid Alex

Schleid Alex

  • NA
  • 361
  • 49k

How to add information from database to list<t>

Jan 13 2020 10:13 AM
Good morning,
 
I am trying to retrieve the list of customer from the database
I have the following code
 
  public List<Customer> ListOfCustomer()
        {
            SqlConnection myCon = new SqlConnection();
            string strConString = ConfigurationManager.ConnectionStrings[0].ConnectionString;
            myCon.ConnectionString = strConString;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "UP_SELECT_CUSTOMER_BY_STOREID";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@StoreID", 1);
            SqlDataAdapter daCustomer = new SqlDataAdapter(cmd);
            DataSet dsCustomer = new DataSet();
            daCustomer.Fill(dsCustomer);
            List<Customer> CustList = new List<Customer>();
            return CustList;
        }
 
I can't figure out how to add the retrieve data to the list
Can someone help me please
 
thank you in advance
 

Answers (1)