如何向向数据库中存储日期!
这是我写的一个代码!向数据库中存储当前时间,可是结过却不是当前时间,请问我还需要在那里做修改啊!
private void DG_BuyOrders_ItemCommand(object source, DataGridCommandEventArgs e)
{
string command=e.CommandName.ToString();
int tempOrderID=Convert.ToInt32(this.DG_BuyOrders.DataKeys[e.Item.ItemIndex]);
string tempDate=DateTime.Now.ToString( "d ");
if(command== "accept ")
{
string tempSql= "Update BuyOrders set Orderstate= '交易完成 ',OrderDateConfirm= "+tempDate+ " where OrderID= "+tempOrderID;
using(Goods good = new Goods())
{
good.UpdataGoods(tempSql);
}
databinding();
}
}
------解决方案--------------------sql: string tempSql= "Update BuyOrders set Orderstate= '交易完成 ',OrderDateConfirm= ' "+DateTime.Now+ " ' where OrderID= "+tempOrderID;
需要加单引号