V
Victor
When I loop through a datatable rows and add Amt field content (which
is float in database) sometimes it adds upto High Precision value
leaving a difference of -1.81898940354586E-12 though I am only adding
Currency Format numbers i.e., 23.43,56.99 etc,So I am not able to
directly compare the total(Computer value) to a value in text field.
Here is the Code
If Session("DT") Is Nothing Then
Dim SQL As String = "SELECT AcctNum, Amount FROM
Accts where 1=2"
Dim Dbase As New DBInterface(DBConnString)
Session("DT") = Dbase.GetDataTable(SQL)
End If
Dim DT As DataTable
DT = Session("DT")
Dim Drow As DataRow = DT.NewRow
Drow("AcctNum") = txtAcct.Text
Drow("Amount") = txtAmt.Text
DT.Rows.Add(Drow)
Dim Total As Double
Dim EachRow As DataRow
For Each EachRow In DT.Rows
Total += EachRow("Amount")
Next
dgrd.Columns.Item(0).FooterText = "Total"
dgrd.Columns.Item(1).FooterText = Total '.ToString("c")
txtTotal.Text = Total
Response.Write(Total - CDbl(txtTotal.Text))
Session("DT") = DT
dgrd.DataSource = DT
dgrd.DataBind()
is float in database) sometimes it adds upto High Precision value
leaving a difference of -1.81898940354586E-12 though I am only adding
Currency Format numbers i.e., 23.43,56.99 etc,So I am not able to
directly compare the total(Computer value) to a value in text field.
Here is the Code
If Session("DT") Is Nothing Then
Dim SQL As String = "SELECT AcctNum, Amount FROM
Accts where 1=2"
Dim Dbase As New DBInterface(DBConnString)
Session("DT") = Dbase.GetDataTable(SQL)
End If
Dim DT As DataTable
DT = Session("DT")
Dim Drow As DataRow = DT.NewRow
Drow("AcctNum") = txtAcct.Text
Drow("Amount") = txtAmt.Text
DT.Rows.Add(Drow)
Dim Total As Double
Dim EachRow As DataRow
For Each EachRow In DT.Rows
Total += EachRow("Amount")
Next
dgrd.Columns.Item(0).FooterText = "Total"
dgrd.Columns.Item(1).FooterText = Total '.ToString("c")
txtTotal.Text = Total
Response.Write(Total - CDbl(txtTotal.Text))
Session("DT") = DT
dgrd.DataSource = DT
dgrd.DataBind()