varchar值'9000437060'的转换溢出了一个int列。超出最大整数值

时间:2014-05-23 18:18:53

标签: .net sql-server debugging stack-trace

我无法搞清楚这个堆栈跟踪,一切都在远离.NET,但由于它全部绑定到IT管理员不愿意升级的2000 MSSQL服务器,我仍然需要处理一些低如果出现问题,可以与之连接的优先级应用。我只看到一个堆叠,但这里似乎有两个。我也不知道它要检查哪个文件,因为问题通常在堆栈顶部?我主要做PHP,所以很多这个对我来说都不熟悉。

筹码在这里。

[SqlException (0x80131904): The conversion of the varchar value '9000437060' overflowed an int column. Maximum integer value exceeded.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950890
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846875
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
   System.Data.SqlClient.SqlDataReader.HasMoreRows() +157
   System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +197
   System.Data.SqlClient.SqlDataReader.Read() +9
   System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) +78
   System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +164
   System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +353
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +164
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +94
   MV.Library.UserHandler.GetByMaryvilleID(String maryvilleID) in C:\Code\MV\MV.Library\User.cs:333

[UserException: UserHandler()::Get: UserHandler - The conversion of the varchar value '9000437060' overflowed an int column. Maximum integer value exceeded.]
   MV.Library.UserHandler.GetByMaryvilleID(String maryvilleID) in C:\Code\MV\MV.Library\User.cs:341
   Apps.rewards.administrator.Event.btnAddAttendee_Click(Object sender, EventArgs e) in C:\Code\Web\Apps\Apps\rewards\administrator\Event.aspx.cs:122
   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 

根据我的研究

该应用程序试图在列中存储比int类型允许的更多字节。我计划将表格列更改为nvarchar或bigint但是想知道这是否是我需要做的全部内容? nvarchar会是更好的选择吗?

提前致谢。

2 个答案:

答案 0 :(得分:4)

int最大值范围为2^32,因此sign = -21474836482147483648或无符号04294967296您的值{{ {1}},更大。您需要一个9000437060,它在SQL中是long

答案 1 :(得分:0)

看起来你正在使用数据库中的值溢出int。尝试将您的c#数据类型更改为long