计划任务 - 溢出

发布于 2024-11-26 10:01:23 字数 1478 浏览 1 评论 0原文

我创建了一个控制台应用程序来运行数据库(大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑忘罢 2024-12-03 10:01:23

我猜你的变量之一出现了数学溢出。尝试将变量显式声明为数据类型,然后将数据行中的数据解析为它们。这将清除错误或为您提供更好的错误消息。

Dim curries as Double = 0
...
curries = Double.Parse(datarow("A"))

实际上,我鼓励您通过在代码中添加 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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文