程序中将数字转换成decimal

SqlCommand mycommand=new SqlCommand("ProMonth",conn);
mycommand.CommandType=CommandType.StoredProcedure;
......
mycommand.Parameters.Add("@UseAmounts",SqlDbType.Decimal).Value=Convert.ToDouble(TextBox00.Text.Trim()); 
conn.Open(); 
mycommand.ExecuteNonQuery();  //出错
存储过程中定义如下:CREATE PROCEDURE ProMonth
@UseAmounts decimal(18,6),
......
总是提示出错,这是为什么呢

解决方案 »

  1.   

    Convert.ToDouble -> Convert.ToDecimal
      

  2.   

    mycommand.Parameters.Add("@UseAmounts",SqlDbType.Decimal).Value=Convert.ToDouble(TextBox00.Text.Trim()); 
    换成
    mycommand.Parameters.Add("@UseAmounts",SqlDbType.Decimal).Value=Convert.ToDecimal(TextBox00.Text.Trim());
      

  3.   

    最好还得控制TextBox00.Text.Trim()不为空
      

  4.   

    可是为什么改了
    mycommand.Parameters.Add("@UseAmounts",SqlDbType.Decimal).Value=Convert.ToDecimal(TextBox00.Text.Trim());
    还是出错呢,错误信息和不改时一样。
      

  5.   

    首先,
    mycommand.Parameters.Add("@UseAmounts",SqlDbType.Decimal).Value=Convert.ToDecimal(TextBox00.Text.Trim()); 然后,贴出你的存储过程