2
Reply

monther calander value from database

Ask a question
ta mu

ta mu

11y
791
1
i am using this code to get stored values of different controls from database. others are ok but monthcalander and datatime picker dont get values from database. i inserted these values using


SqlCommand cmd = new SqlCommand   ("INSERT INTO reminder (message,date,time)     VALUES ('" + textBox1.Text + "','" + monthCalendar1.SelectionStart + "','" + dateTimePicker1.Value + "')", my);

and try to get with this code. no error but why not both controls getting there values.


my.Open();
            string cellvalue = dataGridView1["id", index].Value.ToString();

            SqlCommand cmd = new SqlCommand("SELECT * FROM reminder WHERE id='" + cellvalue + "'", my);
            SqlDataReader rd = cmd.ExecuteReader();
            rd.Read();
            upr.textBox1.Text = rd["message"].ToString();
       
            upr.monthCalendar1.SelectionStart =System.Convert.ToDateTime(rd["date"]);
            upr.label1.Text = rd["id"].ToString();
            upr.dateTimePicker1.Value = System.Convert.ToDateTime(rd["date"]);
            my.Close();

Answers (2)