The root transaction wanted to commit, but transaction aborted

G

Grober

I have a COM+ class with the attribute
[Transaction(TransactionOption.Required)] in which I have a function with
the AutoComplete attribute. The function runs a stored procedure with a
batch job that takes about 10 minutes. However, when execution returns to
the frunction that called the batch function the following error is raised:
"The root transaction wanted to commit, but transaction aborted" and the
batch is rolled back. This doesn't happen when I test the function with a
short SP (less then a minute or something). As you can see in the code below
I set the command timeout to 1000, which is more than enought, but there
seems to be another timeout raised somewhere. Anyone knows what the problem
is?

==== Code snippet ===========================

[AutoComplete]
public DataSet RunSP(string SP, string conString)
{
try
{
// Create connection
SqlConnection con = new SqlConnection(conString);
try
{
// Create command
SqlCommand com = new SqlCommand(SP, con);
com.CommandType = CommandType.StoredProcedure;
com.CommandTimeout = 1000;

// Create adapter
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = com;

// Connect
con.Open();

// Create dataset and fill it
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
catch(Exception)
{
throw;
}
finally
{
con.Close();
}
}
catch (Exception)
{
throw;
}
}
=== End of code snippet ========================
Regards
/Grober
 
G

Grober

No, unfortunately it didn't help. Still same problem. Anyone?

/Grober

Ajay Singh said:
If you raise the transaction timeout then your problem
will get resolved on your class definition add this line

[Transaction(TransactionOption.Required, Timeout:=650)]

Regards
Ajay Singh
-----Original Message-----
I have a COM+ class with the attribute
[Transaction(TransactionOption.Required)] in which I have a function with
the AutoComplete attribute. The function runs a stored procedure with a
batch job that takes about 10 minutes. However, when execution returns to
the frunction that called the batch function the following error is raised:
"The root transaction wanted to commit, but transaction aborted" and the
batch is rolled back. This doesn't happen when I test the function with a
short SP (less then a minute or something). As you can see in the code below
I set the command timeout to 1000, which is more than enought, but there
seems to be another timeout raised somewhere. Anyone knows what the problem
is?

==== Code snippet ===========================

[AutoComplete]
public DataSet RunSP(string SP, string conString)
{
try
{
// Create connection
SqlConnection con = new SqlConnection(conString);
try
{
// Create command
SqlCommand com = new SqlCommand(SP, con);
com.CommandType = CommandType.StoredProcedure;
com.CommandTimeout = 1000;

// Create adapter
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = com;

// Connect
con.Open();

// Create dataset and fill it
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
catch(Exception)
{
throw;
}
finally
{
con.Close();
}
}
catch (Exception)
{
throw;
}
}
=== End of code snippet ========================
Regards
/Grober


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top