myCommand.Parameters["@Num"].Value=Convert.ToInt32(Num.Text.ToString());

解决方案 »

  1.   

    呵呵,可能你的输入里面有空值,需要先做一次判断
    try
    {
    if(Num.Text!=String.Empty)
    {
     myCommand.Parameters["@Num"].Value=int.Parse(Num.Text);
    }
    }
    catch(Exception e1)
    {
    Response.Write(e1.Message);
    }
      

  2.   

    这种方式是没问题的,myCommand.Parameters["@Num"].Value=int.Parse(Num.Text);你跟踪一下Num.Text的具体的值,如果为""则肯定出错,先判断一下
      

  3.   

    先判断一下是否为空:
    if(num.Text != "")
    {
      myCommand.Parameters["@Num"].Value=int.Parse(Num.Text);
    }
    else
    {
      myCommand.Parameters["@Num"].Value=0;
    }
      

  4.   

    先跟踪得到的是什么
    然后试
    myCommand.Parameters["@Num"].Value=int.Parse(Num.Text);