ex.Message:
数字 '108595108629108629108629108629108629108633' 超出了数值表示范围(最大精度为 38)。 数字 '108595108629108629108629108629108629108633' 超出了数值表示范围(最大精度为 38)。
描述:
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() System.Data.SqlClient.SqlDataReader.get_MetaData() System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) Maticsoft.DBUtility.DbHelperSQLP.RunProcedure(String storedProcName, IDataParameter[] parameters, String tableName) Yuyue.DAL.PublicMethod.GetLwcPaging(String table, String where, String filed, String orderfiled, Int32 pageindex, Int32 pagesize, Int32 type, Int32& sum) Yuyue.BLL.Paging.getSumDate(HttpContext context) Yuyue.BLL.Paging.ProcessRequest(HttpContext context) System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
decimal类型表示的数字已经是c#中最大了吧,只能到28位,你这40多位的数字,用什么定义都是超出范围的呀。所以你需要用到大数运算,再大的数字都可以拿来运算。你可以自己实现,用数组表示数字。也可以使用c#的大数,BigInteger类,java中有这个类,c#也应该有,(几千位都可以运算)
如果要存入数据库的话只能先转换成varchar了,再存了。
数字 '108595108629108629108629108629108629108633' 超出了数值表示范围(最大精度为 38)。
这不是很清楚了吗.你的问题是啥
你说的不是很清楚,我猜应该是往数据库里存数据时出现的此错误吧?
假如你数据库字段是int,你往里面存decimal数据,就会有类似的错误,因为你数据库字段的int类型的精度,低于decimal类型的精度,你需要改下数据库字段类型,或者在代码里进行类型转换