我创建了一个存储过程 代码如下:
create proc GetField
 @SourceID int  //整型
as
select FieldID, FieldName,SourceID from [Projection.Field] where SourceID=@SourceID 
go调用调用参数的过程中出现如下错误:
SqlDataAdapter sda = new SqlDataAdapter("GetField", con);
        sda.SelectCommand.CommandType = CommandType.StoredProcedure;
        sda.SelectCommand.Parameters.Add("@SourceID",SqlDbType.Int);
        sda.SelectCommand.Parameters["@SourceID"].Value=this.Projection_Source.SelectedValue;
       
        DataSet ds=new DataSet();
        sda.Fill(ds);
////Failed to convert parameter value from a String to a Int32.
this.Projection_Source--是一个DropDownList控件大虾们帮帮忙呀~~

解决方案 »

  1.   

    sda.SelectCommand.Parameters["@SourceID"].Value = int.Parse(this.Projection_Source.SelectedValue);
      

  2.   

    DropDownList的SelectedValue是一个string,string是不会自己变成Int32的~
      

  3.   

    int.Parse(this.Projection_Source.SelectedValue);
      

  4.   

    如果换成这样:
     sda.SelectCommand.Parameters["@SourceID"].Value = int.Parse(this.Projection_Source.SelectedItem.Value);
    这行提示如下错误:
    Input string was not in a correct format.
    这个应该怎么解决呢??
      

  5.   

    看一下this.Projection_Source.SelectedItem.Value是不是数字~