C# 上载文件时未找到格式正确的输入字符串
我试图在使用ASP.NET构建的网站中获得上传功能。但它总是给我这个错误 “/”应用程序中出现服务器错误 输入字符串的格式不正确。 说明:执行当前web请求期间发生未经处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源 异常详细信息:System.FormatException:输入字符串的格式不正确 源错误:C# 上载文件时未找到格式正确的输入字符串,c#,asp.net,input,syntax-error,C#,Asp.net,Input,Syntax Error,我试图在使用ASP.NET构建的网站中获得上传功能。但它总是给我这个错误 “/”应用程序中出现服务器错误 输入字符串的格式不正确。 说明:执行当前web请求期间发生未经处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源 异常详细信息:System.FormatException:输入字符串的格式不正确 源错误: Line 43:lblDescription.Text = "Problem Description:"; Line 44:txtDescription.Text
Line 43:lblDescription.Text = "Problem Description:";
Line 44:txtDescription.Text = dr["problem_desc"].ToString();
Line 45:this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));
Line 46:break;
Line 47:case "2": //Alter
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12639413
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +224
System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info) +41
eteamuno.module_edit.editvalue() in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:45
eteamuno.module_edit.Page_Load(Object sender, EventArgs e) in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
源文件:C:\eteam\eteam.net-on\eteamno\module\u edit.aspx.cs行:45
堆栈跟踪:
Line 43:lblDescription.Text = "Problem Description:";
Line 44:txtDescription.Text = dr["problem_desc"].ToString();
Line 45:this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));
Line 46:break;
Line 47:case "2": //Alter
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12639413
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +224
System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info) +41
eteamuno.module_edit.editvalue() in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:45
eteamuno.module_edit.Page_Load(Object sender, EventArgs e) in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
有人能帮我吗?将数字字符串转换为数字,而不是调用Int16调用Int32,因为Int16是一个短字符串 Convert.ToInt32()->将字符串数字转换为整数 替换此项:
this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));
this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt32(dr["problem"].ToString()));
包括以下内容:
this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));
this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt32(dr["problem"].ToString()));
发生此异常时,dr[“problem”]
显然不包含数值。里面有什么?当系统遇到不包含有效数值的记录时,您希望系统如何响应?