转换溢出且数值太大而不适合96位十进制。 [英] Conversion overflows and The numerical value is too large to fit into a 96 bit decimal.
问题描述
您好;
我有一个表,其结构如下: -
名称数据类型允许空白
Id int已检查
名称nchar(10)已检查
金额数字(38,20)已检查
销售小数(38,20)已检查
我有一个问题,我通过执行查询从sql绑定表格
从[96bitIssue]中选择*
此表中的数据格式为
ID ID名称销售额
3 aa 715894125.38461538459812461538 757654312.38461538461538461538
4 xdf 753694125.38461538459812461538 757654312.38461538461538461538
5 Neha 235694125.38461538459812461538 757654312.38461538461538461538
6 sandeep 452694125.38461538459812461538 757654312.38 461538461538461538
7 scf 484562125.38461538459812461538
当我使用OleDb Connection我收到此错误
数值值太大,无法容纳96位小数。
使用以下代码..
Hello ;
I have a Table whose structure is as follows:-
Name DataType Allow null
Id int Checked
Name nchar(10) Checked
Amount numeric(38, 20) Checked
sales decimal(38,20) checked
I have an issue in which I am binding a table from sql by executing query
select * from [96bitIssue]
in this table the data are in this format
ID Name Amount Sales
3 aa 715894125.38461538459812461538 757654312.38461538461538461538
4 xdf 753694125.38461538459812461538 757654312.38461538461538461538
5 Neha 235694125.38461538459812461538 757654312.38461538461538461538
6 sandeep 452694125.38461538459812461538 757654312.38461538461538461538
7 scf 484562125.38461538459812461538 757654312.38461538461538461538
When I am using OleDb Connection I am getting this error
The numerical value is too large to fit into a 96 bit decimal.
using following code..
Dim OLEDB_Con As OleDbConnection = New OleDbConnection("Provider=SQLOLEDB;Data Source=NEHA,1433;Initial Catalog=Test;User Id=sa;Password=sa@1234")
Dim da As New OleDbDataAdapter("select * from [dbo].[96bitIssue]", OLEDB_Con)
Dim dt As DataTable = New DataTable()
OLEDB_Con.Open()
da.Fill(dt)
GridControl1.DataSource = dt
当使用SQLConnection时我得到错误转换溢出
And when using SQLConnection I get error Conversion overflows
Dim SQlCon As SqlConnection = New SqlConnection("Data Source=NEHA,1433;Initial Catalog=Test;User Id=sa;Password=sa@1234")
Dim da As New SqlDataAdapter("select * from [dbo].[96bitIssue]", SQlCon)
Dim dt As DataTable = New DataTable()
SQlCon.Open()
da.Fill(dt)
GridControl1.DataSource = dt
请帮助我.....
我们到底出了什么问题,为此解决了什么问题......
Kindly Please help me.....
Exactly we are getting wrong and whats the solution for it......
推荐答案
问题可能很简单; .NET不支持38位精度: http://msdn.microsoft。 com / en-us / library / 364x0z75(v = vs.100).aspx [ ^ ] - 限制为28-29位有效数字。当你试图读取你的值(这是29位数值BTW)时,框架试图说我不适合这个,并抛出一个异常。尝试将SQL精度降低到.NET可以处理的大小,看看是否有效。
The problem is probably quite simple; .NET does not support 38 digit precision: http://msdn.microsoft.com/en-us/library/364x0z75(v=vs.100).aspx[^] - it is limited to 28-29 significant digits. When you try to read your values (which are 29 digit values BTW), the framework is trying to say "I can't fit this in", and throws an exception. Try cutting the SQL precision down to a size that .NET can handle and see if that works.
或者,您可以选择ROUND()值,例如
Alternatively, you can ROUND() the values when you select them, e.g.
SELECT ID, Name, ROUND(Amount, 2) as Amount, ROUND(Sales, 2) as Sales FROM ...
另请参阅http://msdn.microsoft.com/en-us/library/ms175003.aspx [ ^ ]。
这篇关于转换溢出且数值太大而不适合96位十进制。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!