OleDbCommand myC= new OleDbCommand(); 
double price=Convert.ToDouble(textBoxprice.Text.Trim());

string upstr="UPDATE  producer SET Pprice=price*1.2  WHERE Pid='"+this.comboBoxid.Text+"'";
myC.Connection=mainform.Myconnection;
myC.CommandText=upstr;
           
try
{
int rowAffect=myC.ExecuteNonQuery();
if(rowAffect==1)
{


MessageBox.Show("商品入库成功!","提示");
}

}
catch(OleDbException ex)
{
MessageBox.Show(ex.Message,"提示");
}其中double price=Convert.ToDouble(textBoxprice.Text.Trim());
pirce来存textBox的值,可是左边为0.0,右边为输入的数字
报至少一个参数没复值
那为知道怎么来解决

解决方案 »

  1.   

    试一下:double price=Convert.ToDouble(textBoxprice.Text.Trim());改为:double price=0.0;
    if(textBoxprice.Text.Length > 0)
    {
        price=Convert.ToDouble(decimal.Parse(textBoxprice.Text.Trim()));
    }
      

  2.   

    楼上的解释不对!我用这样代码测试
    double price=0.0;if(txtg_meter_cn.Text.Length > 2)
    {
        price=Convert.ToDouble(decimal.Parse(txtg_meter_cn.Text.Trim()));
    }
    else
    {
        price=Convert.ToDouble(txtg_meter_cn.Text.Trim());
    }LZ应该是SQL语句写错了:应该为
    string upstr="UPDATE  producer SET Pprice=" + price*1.2 + "WHERE Pid='"+this.comboBoxid.Text+"'";
      

  3.   

    的确是SQL中price怎么加在引号里了
      

  4.   

    int rowAffect=myC.ExecuteNonQuery();
    写在Try外面试试。
      

  5.   

    string upstr="UPDATE  producer SET Pprice="+price.ToString()+"*1.2  WHERE Pid="+this.comboBoxid.Text+"";pprice 和pid为数字行,不用加'否则比较字符串会0!=0.0