插入数据时提示出错,但找到现在都还不知道怎样错,在数据库中试了是可以的。
string con = ConfigurationManager.ConnectionStrings["SiteMapConnectionString"].ToString();
SqlConnection MyConnection = new SqlConnection(con);
SqlCommand MyCommand1 = new SqlCommand();
try
{
DateTime begintime;
DateTime endtime;
DateTime datetime;
Decimal xiuxitime;
begintime = Convert.ToDateTime(DateB.Text.Trim());
endtime = Convert.ToDateTime(DateE.Text.Trim());
datetime = Convert.ToDateTime(daysrh.Text.Trim());
xiuxitime = Convert.ToDecimal(restMine.Text.Trim());
MyConnection.Open();//’打开数据库
MyCommand1.CommandText = "insert into kanormalkq(wk_no,sanormaltypeno,ddate,begindatetime,enddatetime,notes,shenheren,xiuxitime,totalminute)" +
"values('" + NO.Text.Trim() + "','" + ycType.Text.Trim() + "','" + datetime + "','" + begintime + "','" + endtime + "'," +
"'" + detail.Text.Trim() + "','" + shehe.Text.Trim() + "'," + xiuxitime + ",convert(int,datediff(n,'" + begintime + "','" + endtime + "')) )";
MyCommand1.Connection = MyConnection;
MyCommand1.ExecuteNonQuery();
红色的sql语句究竟错在哪里??请大大们救救我吧!我刚学不久。谢谢。