SqlCommand cmd = new SqlCommand("Insert into [f_present] Values (@faculty_id, @name, @designation, @gender, @date, @status, @remarks)", con.active());
cmd.Parameters.AddWithValue("@faculty_id", fIdtxt.Text);
cmd.Parameters.AddWithValue("@name", fNametxt.Text);
cmd.Parameters.AddWithValue("@designation", fDestxt.Text);
cmd.Parameters.AddWithValue("@gender", fGendertxt.Text);
cmd.Parameters.AddWithValue("@date",dateTimePicker1.Text);
cmd.Parameters.AddWithValue("@status", comboBox1.Text);
cmd.Parameters.AddWithValue("@remarks", remarksTxt.Text);
cmd.ExecuteNonQuery();
I get this error:
Conversion failed when converting date and/or time from character string
DateTimeinstead of as text?insertstatement.AddWithValueis evil. And dispose your command and connection objects withusingblocks