hi,
i have create a program in C# windows application with backend SQl Server 2005.
I have a done coding for save, delete,update. save and delete is working properly.
But update in that i have an error message taht datetime is not in proper format.what should i do to convert datetime in to string..
I provide u all code for update the database.
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\hos.mdf;Integrated Security=True;User Instance=True";
cn.Open();
SqlCommand cmd = new SqlCommand("update outpatient set nm = @nm, addr =@addr,phno = @phno, mobno = @mobno,problem =@problem,docid =@docid,docnm =@docnm,spea = @spea,app = @app, age =@age,[B]dt = @dt[/B],ti = @ti where opid=" + textBox1.Text.ToString() + "", cn);
//cmd.Parameters.AddWithValue("opid", textBox1.Text);
cmd.Parameters.AddWithValue("nm", textBox2.Text);
cmd.Parameters.AddWithValue("addr", textBox3.Text);
cmd.Parameters.AddWithValue("phno", textBox4.Text);
cmd.Parameters.AddWithValue("mobno", textBox5.Text);
cmd.Parameters.AddWithValue("problem", textBox6.Text);
cmd.Parameters.AddWithValue("docid", textBox9.Text);
cmd.Parameters.AddWithValue("docnm", textBox7.Text);
cmd.Parameters.AddWithValue("spea", textBox8.Text);
cmd.Parameters.AddWithValue("app", comboBox1.Text);
cmd.Parameters.AddWithValue("age", textBox10.Text);
[B]cmd.Parameters.AddWithValue("dt", textBox11.Text);[/B]
cmd.Parameters.AddWithValue("ti", comboBox2.Text);
int n = cmd.ExecuteNonQuery();
if (n > 0)
{
MessageBox.Show("Record Updated");
}
cn.Close();
If any one can find the error please let me know...