Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2017, 09:57 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default Delphi5 :Export TAdoDataSet to Excel

Dear Expert,

I am exporting TadoDataSet to Excel from Delphi5 application. All the values are exported properly. But in case of Numeric datatype, there is some error in excel "Number Stored as Text". But if I convert this Numeric datatype to Real , it results in proper value.

Following is the data in TadoDataSet;

HTML Code:
create table test(id int,name nvarchar(24),createddate datetime,amt numeric)
insert test select 1,'Name1','2017-1-1',256.22
insert test select 2,'Name2','2017-1-1',246.22
if i convert the datatype of amt from numeric to real as below, it works properly. what might be the reason.

HTML Code:
create table test(id int,name nvarchar(24),createddate datetime,amt real)
insert test select 1,'Name1','2017-1-1',256.22
insert test select 2,'Name2','2017-1-1',246.22
Thanks in advance.
__________________
Rmt
Reply With Quote
  #2  
Old 10-24-2017, 12:33 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

Isn't numeric an Integer equivalent?
A crappy error, but it would explain this behaviour
Reply With Quote
  #3  
Old 10-24-2017, 02:10 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 199
Default

You didn't mention which database you are using, but you can read here why what you did wouldn't work with MySQL.

From that page:
Quote:
In MySQL, NUMERIC is implemented as DECIMAL, so the following remarks about DECIMAL apply equally to NUMERIC.

salary DECIMAL(5,2)

In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point.

Standard SQL requires that DECIMAL(5,2) be able to store any value with five digits and two decimals, so values that can be stored in the salary column range from -999.99 to 999.99.

In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is permitted to decide the value of M. MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10.

If the scale is 0, DECIMAL values contain no decimal point or fractional part.
Reply With Quote
  #4  
Old 10-24-2017, 02:32 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

See http://www.swissdelphicenter.ch/en/showcode.php?id=998
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #5  
Old 10-27-2017, 04:05 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

Dear Rojam,

I am using sqlserver .
__________________
Rmt
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:15 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.