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.
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).
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
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
Hi Rocky,
Currently the 'Distributed Transaction Coordinator' Service status is started on my Machine.
Sitha Ram
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
I will try that, thanks for the information.
Sitha Ram
Rocky,
Whats the difference between Manual and EnterpriseServices? I'm getting the same error if I use EnterpriseServices but not if I use manual. I'm working with IBM to solve this as well but Id like to understand the difference?
From what I understand transactions in db2 are implied. Meaning that there is a transaction wrapped from one Commit/Rollback to the other.
So I'm just trying to understand what changing out that attribute actually effects.
Thanks
dbl
For a comprehensive answer look at the 2008 book or the 'Using CSLA 4' book.
In summary:
Copyright (c) Marimer LLC