计划任务 - 溢出
我创建了一个控制台应用程序来运行数据库(大约 22K )记录并每晚更新一些值。
我已经向自己添加了一封关于任何错误的电子邮件。运行任务时,我收到大约 500 封电子邮件,内容是:
“溢出”(这是由:Exception.Message 返回的内容),
这是什么意思?它通过数据库运行得太快了吗?我该如何解决这个问题?
谢谢你!
这是我的代码:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你的变量之一出现了数学溢出。尝试将变量显式声明为数据类型,然后将数据行中的数据解析为它们。这将清除错误或为您提供更好的错误消息。
实际上,我鼓励您通过在代码中添加 Option Strict On 并修复编译器发现的每个错误来消除所有隐式转换。
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.
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.