'异常'是一种类型,不能用作表达式和事务中止

时间:2015-06-12 02:23:22

标签: vb.net

我在这里有一个功能,我调试代码,代码运行正常,直到结束,当到达结束时使用它会导致错误,因为事务已中止和“异常”#39;是一种类型,不能用作表达式。请帮助解决这个问题。

以下是代码:

Public Function UpdatePrescriptionStatus(ByVal prescription As Prescription, _
                                     ByRef PrescriptionHeaderID As Int64) As Boolean

Try

    Dim TransactionScopeObject As TransactionScope
    Dim PrescriptionDBObject As New PrescriptionDB
    Dim PrescriptionId As Integer

    TransactionScopeObject = New TransactionScope(TransactionScopeOption.Required)

    Using TransactionScopeObject
        Select Case prescription.StatusID

            Case OnlinePrescriptionStatus.PrescriptionCreated

                PrescriptionId = CreatePrescription(prescription)
                prescription.ID = PrescriptionId
                PrescriptionHeaderID = PrescriptionId
                If PrescriptionId <> 0 Then
                    CreatePrescriptionHistory(prescription)
                End If

            Case OnlinePrescriptionStatus.DoctorApproved
                'OnlinePrescriptionStatus.PrescriptionPartiallyDispensed

                If PrescriptionDBObject.UpdateDoctorAcknowledgedStatus(prescription) Then
                    CreatePrescriptionHistory(prescription)
                End If


        End Select
        TransactionScopeObject.Complete()
        Return True

    End Using

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try

End Function

1 个答案:

答案 0 :(得分:-1)

谢谢大家,我找到了需要将RequiresNew更改为必需的答案。