我在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);
可是运行的时候出错,说是时间格式错误呀,这一句该怎么写呢
先谢谢啦
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);
可是运行的时候出错,说是时间格式错误呀,这一句该怎么写呢
先谢谢啦
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);