我编写了一个代码来存储当前日期和时间值。前天完全按照我的意愿工作。但是今天它显示错误"Arithmetic overflow error converting expression to data type datetime. The statement has been terminated."
有谁能够帮助我?这是我的代码,
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
string q;
q = "insert into tbl_MR(RequirementFor,Category,MRNO,CreatedBy,CreatedDate)values(@rf,@cat,@mr,@cb,@cd)";
SqlCommand cmd = new SqlCommand(q, con);
cmd.Parameters.AddWithValue("@rf", CCddl.SelectedItem.Text);
cmd.Parameters.AddWithValue("@mr", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("@cat", TextBox3.Text.Trim());
cmd.Parameters.AddWithValue("@cb", Session["loginid"].ToString());
string cd1, date1;
cd1 = System.DateTime.Today.ToShortDateString();
date1 = Convert.ToDateTime(cd1).ToString("dd/MM/yyyy");
cmd.Parameters.AddWithValue("@cd", date1.ToString());
cmd.ExecuteNonQuery();
string alertmessage = "";
alertmessage = "Component Details Saved";
this.CreateMessageAlert(this, alertmessage, "alertKey");
con.Close();
}