2 つのクエリで DB にレコードを挿入するプログラムがあります。そこでトランザクションを処理しています。しかし、私の取引は機能していません。first statement を実行した後、プログラム レコードを閉じると、最初のテーブルが挿入され、2 番目のテーブルには挿入されません。
しかし、それは最初のテーブルからロールバックする必要があります。ここでの問題は何ですか。
Try
objBLlCommonFunction.BeginTransaction()
For j As Integer = 0 To dgstkReceivd.VisibleRowCount - 1
objBllStcTransaction.InsertStockTransferExcelDetail(InvNo, lblDateI.Text)
Next
objBllStcTransaction.InsertStockTransferExcelHeader(InvNo, dbId)
ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "message", "alert('" + "Successfully Saved" + "');", True)
objBLlCommonFunction.CommitTransaction()
Catch ex As Exception
objBLlCommonFunction.RollbackTransaction()
objerror.AddToErrorLog(ex.StackTrace, ex.Message)
ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "message", "alert('" + ex.Message + "');", True)
End Try