Return to Snippet

Revision: 36598
at November 24, 2010 02:40 by brandonroath


Initial Code
private Dictionary<string, int> Data
        {
            get
            {
                Dictionary<string, int> data = new Dictionary<string, int>();

                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    SqlDataReader rdr = null;

                    conn.Open();

                    string query = "";

                    SqlCommand cmd = new SqlCommand(query, conn);

                    using (rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            data.Add(((DateTime)rdr["date"]).ToString("MM-yyyy"), (int)rdr["visits"]);
                        }
                    }
                }
                return data;
            }
        }

Initial URL

                                

Initial Description

                                

Initial Title
Basic SQL access

Initial Tags
sql, c#

Initial Language
C#