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,右边为输入的数字
报至少一个参数没复值
那为知道怎么来解决
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,右边为输入的数字
报至少一个参数没复值
那为知道怎么来解决
if(textBoxprice.Text.Length > 0)
{
price=Convert.ToDouble(decimal.Parse(textBoxprice.Text.Trim()));
}
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+"'";
写在Try外面试试。