Hello people,

I have an application that updates a table. In this application i have a combobox where i load id of record
on form load. Let me paste my code to be more clear about my problem.

Private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

  string q = "Select AREA, [PAYING AUTHORITY],[PURCHASE ORDER No], [BILL No], [BILL DATED], [MATERIAL VALUE], [BILL VALUE], [AMOUNT PASSED] , [SUPPLY PARTICULAR], [PAYMENT DETAILS], [C-FORM No], T_ID  from transact1 where t_id = '" +comboBox1.SelectedItem+ "' ";

                SqlCommand cmmd = new SqlCommand(q, on6);

                SqlDataReader drr = cmmd.ExecuteReader();

                while (drr.Read())
                    //MessageBox.Show("Record With this Transaction Exist. Please Press OK to Continue.....");

                    txtarea.Text = drr["AREA"].ToString();
                    textBox2.Text = drr["PAYING AUTHORITY"].ToString();
                    richdescp.Text = drr["PURCHASE ORDER No"].ToString();
                    txtbill.Text = drr["BILL No"].ToString();
                    dateTimePicker1.Text = drr["BILL DATED"].ToString();
                    txtamt.Text = drr["MATERIAL VALUE"].ToString();
                    txtamtpas.Text = drr["BILL VALUE"].ToString();
                    textBox1.Text = drr["AMOUNT PASSED"].ToString();
                    richrem.Text = drr["SUPPLY PARTICULAR"].ToString();
                    txtchq.Text = drr["PAYMENT DETAILS"].ToString();
                    textBox3.Text = drr["C-FORM No"].ToString();




            catch (Exception ex)

Everytime i try to load data in the form. It gives me error that "String was not recognized as valid date time".
I tried lot of things but it didn't help. Can anybody please help me with this problem?

Thanks and Regards

You have an error on row No.20. It should be like this:

dateTimePicker1.Value = Convert.ToDatetime(drr["BILL DATED"]);
commented: Nice. +9