输入字符串的格式不正确。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 
行 308:            }
行 309:        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
行 310:        int howManyProducts =Int32.Parse(comm.Parameters["@HowManyResults"].Value.ToString());
行 311:        howManyPages = (int)Math.Ceiling((double)howManyProducts /
行 312:                                           (double)BalloonShopConfiguration.ProductsPerPage); 
 源文件: d:\我做的VB项目\Shopping\App_Code\CatalogAccess.cs    行: 310 堆栈跟踪: 
[FormatException: 输入字符串的格式不正确。]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753235
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
   System.Int32.Parse(String s) +20
   CatalogAccess.Search(String searchString, String allWords, String pageNumber, Int32& howManyPages) in d:\我做的VB项目\Shopping\App_Code\CatalogAccess.cs:310
   ProductsList.PopulateControls() in d:\我做的VB项目\Shopping\UserControls\ProductsList.ascx.cs:32
   ProductsList.Page_Load(Object sender, EventArgs e) in d:\我做的VB项目\Shopping\UserControls\ProductsList.ascx.cs:17
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
   System.Web.UI.Control.OnLoad(EventArgs e) +88
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3036 
一按搜索就出现错误,是什么问题啊????

解决方案 »

  1.   

    不是写得很清楚嘛,
    d:\我做的VB项目\Shopping\App_Code\CatalogAccess.cs    行: 310 
    输入格式不正确
    行 310:        int howManyProducts =Int32.Parse(comm.Parameters["@HowManyResults"].Value.ToString()); 
    可能无法转换成int32
      

  2.   

    comm.Parameters["@HowManyResults"].Value.ToString()); 你先调式一下.看看它的值是什么不就OK了.如果是null.你这种转法肯定是会报错的
    像这种转换的之类.最好是用Convert来转换.
      

  3.   

     是函数ALTER FUNCTION [dbo].[WordCount]
    (@Word VARCHAR(15), 
    @Phrase VARCHAR(1000))
    RETURNS SMALLINT
    AS 是写的一个数据存储过程   HowManyResults的格式是 SMALLINT
      

  4.   

    存储过程中参数是out类型的吗?
    无论什么情况下都会有值而不是null吗?
      

  5.   

    dbo.SearchCatalog
    参数
    @DescriptionLength(ing,输入,无默认值)
    @PageNumber(tinyint,输入,无默认值)
    @ProductsPerPage(tinyint,输入,无默认值)
    @HowManyResult(smallint,输入/输出,无默认值)
    @AllWords(bit,输入,无默认值)
    @Word1(varchar(15),输入,无默认值)
    @Word2(varchar(15),输入,无默认值)
    @Word2(varchar(15),输入,无默认值)
    @Word2(varchar(15),输入,无默认值)
    @Word2(varchar(15),输入,无默认值)
    返回integer标量值函数
    dbo.WordCount
    参数
    @Word(varchar(15),无默认值)
    @Phrase(varchar(1000),无默认值)
      

  6.   

    @DescriptionLength(ing,输入,无默认值)没用过这个ING
      

  7.   

    int 是我打上来打错了
    dbo.SearchCatalog 
    参数 
    @DescriptionLength(int,输入,无默认值) 
    @PageNumber(tinyint,输入,无默认值) 
    @ProductsPerPage(tinyint,输入,无默认值) 
    @HowManyResult(smallint,输入/输出,无默认值) 
    @AllWords(bit,输入,无默认值) 
    @Word1(varchar(15),输入,无默认值) 
    @Word2(varchar(15),输入,无默认值) 
    @Word2(varchar(15),输入,无默认值) 
    @Word2(varchar(15),输入,无默认值) 
    @Word2(varchar(15),输入,无默认值) 
    返回integer 标量值函数 
    dbo.WordCount 
    参数 
    @Word(varchar(15),无默认值) 
    @Phrase(varchar(1000),无默认值)