我在SQL数据库里定义了一个表,有这样的一个字段
create table aa(
updatetime datetime not null
)
现在在.NET平台中通过按钮添加字段,
insert 语句如下:
string time=System.DateTime.Now .ToString ();

  SqlCommand cmd=new SqlCommand ("insert into newsword newsid,newstitle,newscontent,updatetime) values('"+id+"','"+this.txtttile .Text.Trim () +"','"+this.txtword .Text .Trim ()+"','"+time+"'",con);
可是运行的时候出错,说是时间格式错误呀,这一句该怎么写呢
先谢谢啦

解决方案 »

  1.   

    sql语句少了个(括号
    SqlCommand cmd=new SqlCommand ("insert into newsword (newsid,newstitle,newscontent,updatetime) values('"+id+"','"+this.txtttile .Text.Trim () +"','"+this.txtword .Text .Trim ()+"','"+ System.DateTime.Now.ToString()+"'",con);
      

  2.   

    SqlCommand cmd=new SqlCommand ("insert into newsword (newsid,newstitle,newscontent,updatetime) values('"+id+"','"+this.txtttile .Text.Trim () +"','"+this.txtword .Text .Trim ()+"','"+time+"')",con);
      

  3.   

    SqlCommand cmd = new SqlCommand ("insert into newsword (newsid,newstitle,newscontent,updatetime) value('" + id + "','" + this.txtttile.Text.Trim() + "','" + this.txtword.Text .Trim ()+ "','" + time + "')",con);//结尾还少了一个括号
      

  4.   

    string time=System.DateTime.Now .ToString ();  SqlCommand cmd=new SqlCommand ("insert into newsword( newsid,newstitle,newscontent,updatetime) values('"+id+"','"+this.txtttile .Text.Trim () +"','"+this.txtword .Text .Trim ()+"','"+time+"')",con);