先需要通过ASP.NET 更新SQL SERVER2000 中的DateTime类型 遇到了困难,还请高手指教..
代码如下:
SqlCommand cmd=new SqlCommand( "Update Employees set birthdate= "+((TextBox)(e.Item.FindControl( "txtBirth "))).Text+ " where EmployeeID= "+this.DataList1.DataKeys[e.Item.ItemIndex].ToString(),con);
其中BirthDate是DateTime类型的...
先谢谢各位了..
------解决方案--------------------------------------------------------
一看就是类型不对,你该先string 转换成DateTime类型
------解决方案--------------------------------------------------------
SqlCommand cmd=new SqlCommand( "Update Employees set birthdate = " + Convert.ToDateTime(((TextBox)(e.Item.FindControl( "txtBirth "))).Text) + " where EmployeeID= "+this.DataList1.DataKeys[e.Item.ItemIndex].ToString(),con);