RS.GetValue (RS.GetOrdinal ("balance")) gives an unexpected value

I use Visual Studio 2005 along with mysql 4.0, I have a table with a field (decimal 16.4) that stores the invoice amount and another table with payments for this account (fields are also decimal 16.4)

I read the data and get some records with 4 columns (account, amount, payments, balance)

invoice 454, Amount 8125.68 payments: 8125.68 balance : 0 

Payments are made from the amount (payments).

Record data from the relevant payments: 8122.16, 0.0900, 0.0050, 1.6900, 1.7350

total number is 8125.68

I read the following data:

 Dim Conn As New MySqlConnection(myConnString) Dim RS As MySqlDataReader dim Q as string="SELECT.........." ' MYSQL STATEMENT Dim CM As New MySqlCommand(Q, Conn) RS = CM.ExecuteReader While RS.Read RS.GetValue(RS.GetOrdinal("invoice")) RS.GetValue(RS.GetOrdinal("amount")) RS.GetValue(RS.GetOrdinal("payments")) RS.GetValue(RS.GetOrdinal("balance")) End While 

And everything works fine, but the meaning of this:

 RS.GetValue(RS.GetOrdinal("balance")) 

there is 0.000000009456544 , not 0.00 ! What's going on here?

+4
source share
1 answer

I think DECIMAL used DOUBLE in the dark times of MySQL 4.0. Hence the terrible results and comments.

(The answer is to remove from unanswered.)

0
source

Source: https://habr.com/ru/post/1443122/


All Articles