积极答复者
异常详细信息: System.FormatException: 输入字符串的格式不正确。

问题
-
输入格式不正确,请各位高手快来帮忙:
原始代码:
285 int howManyBooks=Int32.Parse(comm.Parameters["@HowManyBooks"].Value.ToString());
286 howManyPages=(int)Math.Ceiling((double)howManyBooks /(double)LadderConfiguration.BooksPerPage);输入字符串的格式不正确。
异常详细信息: System.FormatException: 输入字符串的格式不正确。
源错误:
行 284: DataTable table=GenericDataAccess.ExecuteSelectCommand(comm);
行 285: int howManyBooks=Int32.Parse(comm.Parameters["@HowManyBooks"].Value.ToString());
行 286: howManyPages=(int)Math.Ceiling((double)howManyBooks /(double)LadderConfiguration.BooksPerPage);
行 287: return table;
堆栈跟踪:
[FormatException: 输入字符串的格式不正确。]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471623
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
System.Int32.Parse(String s) +23
CatalogAccess.GetBooksOnDepartmentPromotion(String deparmentId, String pageNumber, Int32& howManyPages) in c:\inetpub\wwwroot\LadderNet\App_Code\CatalogAccess.cs:285
UserControls_BookList.PopulateContorls() in c:\inetpub\wwwroot\LadderNet\UserControls\BookList.ascx.cs:50
UserControls_BookList.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\LadderNet\UserControls\BookList.ascx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627当把285行换成如下:
int howManyBooks=Int32.Parse(comm.Parameters[0].Value.ToString());
(即把"@HowManyBooks"换成0或2或3)时,一切正常,就是少了"@HowManyBooks"的功能.
但是把"@HowManyBooks"换成1时,"@HowManyBooks"的功能也有了,但是不符合逻辑.
当把"@HowManyBooks"换成4时,错误跟不换时是一样的.
当把"@HowManyBooks"换成>=5的数字时时:
异常详细信息: System.IndexOutOfRangeException: 此 SqlParameterCollection 的 Count=5 的索引 100 无效。
当把"@HowManyBooks"换成"*"(*代表任何字符,包括空格和空字符)(或"*"为null)时:
异常详细信息: System.IndexOutOfRangeException: 此 SqlParameterCollection 中未包含带有 ParameterName“*”的 SqlParameter。
当把"@HowManyBooks"换成字符时(包括空格和空字符),直接就不能编译.注:"@HowManyBooks"是数据库存储过程的输出参数,标明了int型.当然有可能为0,但不会为字符.