Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 多年后,Int16的值要么太大,要么太小_C#_Asp.net_Visual Studio_Deployment_Iis 7 - Fatal编程技术网

C# 多年后,Int16的值要么太大,要么太小

C# 多年后,Int16的值要么太大,要么太小,c#,asp.net,visual-studio,deployment,iis-7,C#,Asp.net,Visual Studio,Deployment,Iis 7,我的一个应用程序从2005年开始运行。现在它给出了下面提到的错误 我不知道发生了什么事。有人面临过这样的问题吗 Server Error in '/' Application. Value was either too large or too small for an Int16. Description: An unhandled exception occurred during the execution of the current web request. Please review

我的一个应用程序从2005年开始运行。现在它给出了下面提到的错误

我不知道发生了什么事。有人面临过这样的问题吗

Server Error in '/' Application.
Value was either too large or too small for an Int16.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Exception: Value was either too large or too small for an Int16.
Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 
[Exception: Value was either too large or too small for an Int16.]
   Attach_DL.Generatekey() +121
   Attach_BL.GenerateKey() +12
   Picture.AddAttachments(String _attachpath, String _attachpathDB) +289
   Picture.Btnsave_Click(Object sender, EventArgs e) +1416
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

怀疑结果包含
Int16
无法保存的较大值。所有类型的整数具有不同的以下存储容量范围

Int 16 -- (-32768 to +32787)

自2005年以来,您的字段可能会增加,现在的值超过32787


EF根据DB types生成您的字段,numeric(5)可能会给出int16,即使它可以容纳99999

我不能仅从堆栈跟踪中分辨出多少(即,提供堆栈跟踪引用的代码会很有帮助)。我要指出,int16的最大大小是
32767
(正或负)。根据stacktrace,您的应用程序正试图将大于或小于该值的值放入Int16变量中。您在应用程序中使用的数据类型为Int16的字段可能已超过值32767。请发布
Attach_DL.Generatekey()
的源代码。我正在将相同的记录保存多年。没有一个领域我给出了巨大的数字。为什么其他数据像以前一样保存?@MuhammadFahad主键?没有兄弟。事实上,我的问题是,为什么它在使用我们以前保存的相同数据集多年后出现错误。@MuhammadFahad是的,他的意思是主键值可能已经超过32787,就像你现在有那么多记录一样。