简体   繁体   中英

ADODB decimal in VB6 / VB.NET

I have a data access component using ADODB (MDAC 2.8) that uses an ADODB.recordset to read a sql server table containing a column defined as decimal(15,2).

This data access component is written in VB6 and is used in our software for years now.

Now we must write a compatible component without VB6 (so we did a rewrite in VB.NET).

For easier shift to the new component we sticked to use ADODB from VB.NET.

Now the question: If I read a value from the column that contains the data of "50000" (no decimals) and return it as a string, the vb6 component delivers "50000", where the VBNET version delivers "50000,00".

So this may be a cosmetic issue only as internal representaion is ok but I wonder if there is a switch to determine how the decimals are returned.

In addition: any links refering this compatibility issues in this range are welcome...

Regards Klaus

I see two big mistakes here:

For easier shift to the new component we sticked to use ADODB from VB.NET.

There's no good reason for this. You'll thank yourself sooner (not later) for using the ADO.Net API rather than the older ADODB.

If I read a value from the column that contains the data of "50000" (no decimals) and return it as a string

Ugh. Keep numeric data as numeric data. Use the Decimal type throughout your code, right up to last possible moment before you actually display the data to the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM