把Price的单引号去掉试试SqlCommand   Updatecmd=new   SqlCommand("update   prices   set   sPrice='"+Price+"'   where   sID='"+ID+"'",Updatecon);   //数据表名prices   价格 
改成
SqlCommand   Updatecmd=new   SqlCommand("update   prices   set   sPrice="+Price+"   where   sID='"+ID+"'",Updatecon);   //数据表名prices   价格 

解决方案 »

  1.   

    不行啊,去掉后点"更新"按钮提示:where附近有语法错误 ?__?
      

  2.   

    string sql="update   prices   set   sPrice="+Price+"   where   sID='"+ID+"'";
    SqlCommand   Updatecmd=new   SqlCommand(sql,Updatecon);
      

  3.   

    wangkun9999大大,这样似乎效果一样,我试了下还是 "where附近有语法错误",DataGrid编辑列点"更新"时出错...
      

  4.   

    ToDecimal  Price=Convert.ToDecimal(((TextBox)(e.Item.Cells[3].Controls[1])).Text.Trim());
      

  5.   


    Decimal  Price=Convert.ToDecimal(((TextBox)(e.Item.Cells[3].Controls[1])).Text.Trim()); 
      

  6.   

    我将类型改为decimal,并使用以上语句,错误提示:输入字符串的格式不正确。
    晕了..还是谢谢楼上的朋友^^
      

  7.   

    我将Price单引号去掉了的,"update   prices   set   sPrice="+Price+"   where   sID='"+ID+"'"
      

  8.   

    把生成的sql语句直接放数据库里试~--!
      

  9.   

    数据库中price字段要是Decimal类型的,然后按照1楼写SQL语句,在更新之前,将输入价格的输入框进行转换:
    decimal Price=decimal.Parse(TextBox1.Text.Trim());
    按照这个流程来,应该没问题。
      

  10.   

    SqlCommand   Updatecmd=new   SqlCommand("update   prices   set   sPrice='"+Price+"'   where   sID='"+ID+"'",Updatecon);   //数据表名prices   价格 
    改成
    SqlCommand   Updatecmd=new   SqlCommand("update   prices   set   sPrice="+Price+"   where   sID="+ID+"",Updatecon);   //数据表名prices   价格 int  类型的不要用 '  符号,呵
      

  11.   

    int ID=this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); 
    decimal   Price=decimal.Parse(TextBox1.Text.Trim()); 要和数据库里的字段相对应!!!!!!!!!!!!!!!!!!!!!!!!!!1
      

  12.   

    ("update   prices   set   sPrice='"+Price+"'   where   sID='"+ID+"')
    把这个放sql看能运行通过不~