CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

Transaction handling in CLSA.NET

Last post 05-12-2008, 10:30 AM by gsitaramireddy. 6 replies.
Sort Posts: Previous Next
  •  04-30-2008, 1:49 PM 23215

    Transaction handling in CLSA.NET

    Hi I am new to CSLA.net, I want to learn more about it.

    When I am trying to delete a record from DB2 database, I am getting the below error and inner exception 

    at the line  "connEmp.Open();" in my code sample.

    Error:  "ERROR [58005] [IBM][DB2/6000] SQL0998N Error occurred during transaction or heuristic processing. Reason Code = "16". Subcode = "2-8004D026". SQLSTATE=58005"
    Inner Exception: "_COMPlusExceptioncode -532459699"

    Below are two ways I tried.

    [Transactional(TransactionalTypes.TransactionScope)]
            private void DataPortal_Delete(Criteria criteria)
            {
                using (DB2Connection connEmp = new DB2Connection(Databases.EmpDBConnection))
                {
                    connEmp.Open();

                    using (DB2Command cmdEmp = connEmp.CreateCommand())
                    {
                        string strSQL = "SP_DELETE_Employee";
                        cmdEmp.CommandType = CommandType.StoredProcedure;
                        cmdEmp.CommandText = strSQL;
                        cmdEmp.Parameters.Add("EmpID",criteria.EmpId);
                        cmdEmp.ExecuteNonQuery();
                    }
                }
            }

    and

    [Transactional(TransactionalTypes.TransactionScope)]
    private void DataPortal_Delete(Criteria criteria)
    {
           Database dbEmp = DatabaseFactory.CreateDatabase();
           System.Data.Common.DbCommand dbCommand = dbEmp.GetStoredProcCommand("SP_DELETE_Employee");
           dbEmp.AddInParameter(dbCommand, "EmpID", DbType.Int16, criteria.empId);
           dbEmp.ExecuteNonQuery(dbCommand);
    }

     

    Distributed transaction coordinator service also running on my machine.

    I added below code in web.config to change the default transaction time out

    <system.transactions>

        <defaultSettings timeout="00:010:00" />

      </system.transactions>


    I am using below softwares list

    Visual Studio 2005,ASP.NET 2.0,CSLA.NET 3.0.4,UDB DB2 9.1.2 database,C#.NET and Microsoft Enterprise Library 3.1 and Windows XP with SP2.

    Is it mandatory to run the MDT service to work with CSLA Transactions, if not can you please advise me the best solution to resolve this problem.

    If I removed transaction attribute ([Transactional(TransactionalTypes.TransactionScope)]) it was working fine in both the cases.

    Can some one please help me to work with transactions in CSLA.net.

  •  05-02-2008, 9:31 AM 23278 in reply to 23215

    Re: Transaction handling in CLSA.NET

    I don't think DB2 provides support for System.Transactions.TransactionScope?

    I think you need to use either manual ADO.NET transactions or Enterprise Services with DB2.

    So use

    [Transactional(TransactionalTypes.EnterpriseServices)]

    and you should be good (assuming your machine is configured to allow the DTC to work).


    Rocky
  •  05-05-2008, 12:09 PM 23338 in reply to 23278

    Re: Transaction handling in CLSA.NET

    Thank you very much for support, but I am getting "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) " error.

    When I use [Transactional(TransactionalTypes.EnterpriseServices)]

     

    Sitha Ram

  •  05-05-2008, 1:03 PM 23340 in reply to 23338

    RE: Transaction handling in CLSA.NET

    You probably need to enable DTC on your machine – it is disabled by default with WinXP SP2 and higher.

     

    Rocky

     

    From: gsitaramireddy [mailto:cslanet@lhotka.net]
    Sent: Monday, May 05, 2008 12:10 PM
    To: rocky@lhotka.net
    Subject: Re: [CSLA .NET] Transaction handling in CLSA.NET

     

    Thank you very much for support, but I am getting "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) " error.

    When I use [Transactional(TransactionalTypes.EnterpriseServices)]

     

    Sitha Ram




    Rocky
  •  05-06-2008, 8:31 AM 23355 in reply to 23340

    Re: RE: Transaction handling in CLSA.NET

    Hi Rocky,

    Currently the 'Distributed Transaction Coordinator' Service status is started on my Machine.

    Sitha Ram

     

  •  05-06-2008, 9:06 AM 23358 in reply to 23355

    RE: RE: Transaction handling in CLSA.NET

    There is an MSDN knowledge base article on how to enable the DTC – it is more than just the service, because the windows firewall blocks it too.

     

    Otherwise I don’t know what to suggest.

     

    Rocky

     

     

    From: gsitaramireddy [mailto:cslanet@lhotka.net]
    Sent: Tuesday, May 06, 2008 8:32 AM
    To: rocky@lhotka.net
    Subject: Re: [CSLA .NET] RE: Transaction handling in CLSA.NET

     

    Hi Rocky,

    Currently the 'Distributed Transaction Coordinator' Service status is started on my Machine.

    Sitha Ram

     




    Rocky
  •  05-12-2008, 10:30 AM 23515 in reply to 23358

    Re: RE: RE: Transaction handling in CLSA.NET

    I will try that, thanks for the information.

    Sitha Ram

View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems