Reputation: 6615
I have created a console application to run through the db (about 22K )records and update some values nightly.
i've added an email to myself on any errors. when running the task i get about 500 emails saying:
"Overflow" (which is what's returned by : exception.Message)
what does it mean? is it running through the db too fast? how can i fix this?
Thank you!
here is my code:
For Each dataRow As DataRow In dt.Rows
curries = 0
baseDate = Nothing
sourceID = 0
isotopeID = 0
currentCat = 0
act = 0
cat = 0
isoDetails = Nothing
Try
If (Not curries = "0") And IsNumeric(curries) Then
A= dataRow("A")
B= dataRow("B")
C= dataRow("C")
D= dataRow("D")
act = CalculateActivity(A, B, dataRow("E"))
cSource.UpdateDB(A, B, dataRow("E"), act, Now())
isoDetails = cSource.GetLookUpDetails(dataRow("E"))
cSource.UpdateCategory(sourceID, cat)
End If
Catch ex As Exception
ErrorOnUpdate(sourceID, isotopeID, ex.Message)
End Try
Next
..........
Public Function CalculateIsotopeActivity(ByVal curries As Double, ByVal actibityDate As DateTime, ByVal isotope As String) As Double
'reported activity * e^(-Log(2) * ((now - activity date)/365)/halflife))
Return curries * Math.E ^ (-Math.Log(2) * (((Now.Date().Subtract(DateTime.Parse(actibityDate)).Days) / 365) / cSource.GetIsotopeLookUpDetails(isotope).HalfLife))
End Function
Upvotes: 0
Views: 420
Reputation: 4585
I would guess that you are getting a mathematical overflow on one of your variables. Try explicitly declaring your variables to a datatype and then parsing the data from the datarow into them. This will either clear up the errors or give you better error messages.
Dim curries as Double = 0
...
curries = Double.Parse(datarow("A"))
I would actually encourage you to eliminate all the implicit conversion by adding Option Strict On to your code and fixing every error the compiler finds.
Upvotes: 1