Posted By

brandonroath on 11/24/10


Tagged

sql c#


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

brandonroath


Basic SQL access


 / Published in: C#
 

  1. private Dictionary<string, int> Data
  2. {
  3. get
  4. {
  5. Dictionary<string, int> data = new Dictionary<string, int>();
  6.  
  7. using (SqlConnection conn = new SqlConnection(connectionString))
  8. {
  9. SqlDataReader rdr = null;
  10.  
  11. conn.Open();
  12.  
  13. string query = "";
  14.  
  15. SqlCommand cmd = new SqlCommand(query, conn);
  16.  
  17. using (rdr = cmd.ExecuteReader())
  18. {
  19. while (rdr.Read())
  20. {
  21. data.Add(((DateTime)rdr["date"]).ToString("MM-yyyy"), (int)rdr["visits"]);
  22. }
  23. }
  24. }
  25. return data;
  26. }
  27. }

Report this snippet  

You need to login to post a comment.