| |

VerySource

 Forgot password?
 Register
Search
View: 602|Reply: 3

vb.net on type conversion and retention of two decimal places

[Copy link]

3

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-19 14:20:01
| Show all posts |Read mode
How can I keep the two digits after the decimal point from the recordset?
Response.Write (rs ("test"). Value)
The output is
1.36894117647059
How can I keep the two digits after the decimal point?
Reply

Use magic Report

1

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-26 17:36:02
| Show all posts
Math.Round (rs ("test"). Value, 2)
Reply

Use magic Report

3

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-27 15:36:02
| Show all posts
Will report an error

Exception Details: System.Reflection.AmbiguousMatchException: The overload decision failed because there is no Public "Round" that can be called with these parameters:
   'Public Shared Function Round (d As Decimal, decimals As Integer) As Decimal':
       A parameter matching the parameter "d" cannot be converted from "DBNull" to "Decimal".
   'Public Shared Function Round (d As Decimal, mode As System.MidpointRounding) As Decimal':
       A parameter matching the parameter "d" cannot be converted from "DBNull" to "Decimal".
   'Public Shared Function Round (value As Double, digits As Integer) As Double':
       Parameters matching the parameter "value" cannot be converted from "DBNull" to "Double".
   'Public Shared Function Round (value As Double, mode As System.MidpointRounding) As Double':
       Parameters matching the parameter "value" cannot be converted from "DBNull" to "Double".
Reply

Use magic Report

1

Threads

10

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-30 21:18:01
| Show all posts
double i = convert.todouble (rs ("test"). value);
Math.Round (i, 2)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list