日期:2014-05-19  浏览次数:20378 次

Update的错误在那啊!谁能告诉我!
我写了个Update的语句可是总报错,谁能告诉我错在哪里了啊!谢谢!
string   tempGoodsName=this.txtGoodsName.Text.Trim();
string   tempGoodsNum=this.txtGoodsNum.Text.Trim();
string   tempGoodsDes=this.txtGoodDes.Text.Trim();
string   tempGoodsPrice=this.txtGoodsPrice.Text.Trim();
string   Sql= "Update   GoodsInfo   set   GoodsName= "+tempGoodsName+ ",GoodsNum= "+tempGoodsNum+ ",GoodsDes= "+tempGoodsDes+ ",GoodsPrice= "+tempGoodsPrice+ "   where   GoodsID= "+goodsID;
using(Goods   good   =   new   Goods())
{
good.UpdataGoods(Sql);
}

------解决方案--------------------
字符串两边要加单引号
------解决方案--------------------
字符串要用单引号
string Sql= "Update GoodsInfo set GoodsName= ' "+tempGoodsName+ " ',GoodsNum= ' "+tempGoodsNum+ " ',GoodsDes= ' "+tempGoodsDes+ " ',GoodsPrice= ' "+tempGoodsPrice+ " ' where GoodsID= "+goodsID;