I have a program that inserting records to DB in 2 queries.And I'm handling the transaction there. But my transaction is not working. After executing first statement , if I close the program records will insert the first table and not inserting to the second.
But that should rollback from first table. What is the issue here.
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