title: How to retrieve data from sql server database and manipulate it in c#?
body: <p>I am new to asp.net. I am trying to retrieve data from SQL Server in an asp.net website. This is the result of my table in SQL,</p>
  
  <pre><code>Day_Of_Week    Product_Count
  -----------------------------
  Sunday              8
  Monday            150
  Tuesday            80
  Wednesday          95
  Thursday          345
  Friday            229
  Saturday           48
  </code></pre>
  
  <p>This is my code in c#,</p>
  
  <pre><code>    DataTable dt = new DataTable();
      SqlConnection con = new SqlConnection(Settings.DatabaseConnectionString);
      SqlCommand com = new SqlCommand("Select * from tblProducts");
      com.CommandType = CommandType.Text;
      com.Connection = con;
      con.Open();
      SqlDataAdapter da = new SqlDataAdapter(com);
      da.Fill(dt); 
  
     int monday = Convert.ToInt32(dt.Rows[1]["Product_Count"]);
     int tuesday = monday + Convert.ToInt32(dt.Rows[2]["Product_Count"]);
     int wednesday = tuesday + Convert.ToInt32(dt.Rows[3]["Product_Count"]);
     int thursday = wednesday + Convert.ToInt32(dt.Rows[4]["Product_Count"]) ;
     int friday = thursday + Convert.ToInt32(dt.Rows[5]["Product_Count"]);
  </code></pre>
  
  <p>Now, if there are no records on Sunday, it does not display Sunday row and I have to change the c# code. Instead, I want to put a switch case or something so that if the day is Monday, then I can write dt.Rows[0], if the day is Tuesday, then dt.Rows[0], etc.</p>
  
  <p>Let me know what would be the best option to do this. Any help will be appreciated.</p>
  
  <p>Thanks.</p>