Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
VB
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



And when using SQLConnection I get error Conversion overflows
VB
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......
Posted
Updated 1-Aug-13 4:58am
v3
Comments
Dave Kreskowiak 1-Aug-13 8:06am    
Which database engine are you using?

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.
 
Share this answer
 
Comments
Maciej Los 1-Aug-13 11:34am    
I didn't knew it...
5!
Alternatively, you can ROUND() the values when you select them, e.g.
SQL
SELECT ID, Name, ROUND(Amount, 2) as Amount, ROUND(Sales, 2) as Sales FROM ...

See also http://msdn.microsoft.com/en-us/library/ms175003.aspx[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900