SQLException timeout with nested Queries

  • Thread starter Thread starter Gerrit.Horeis
  • Start date Start date
G

Gerrit.Horeis

Hi All,
I have a problem with nested SQLQueries. I will give here an abstract
sample of code which I wrote

Method A
{
createSqlTransaction and
call SQL Insert Statement including "Select ScopeIdentity();"
try
{
call Method B
}
catch
{
Rollback Transaction
}
}

Method B
{
call another SQL Insert Statement including "Select ScopeIdentity();"
....
}


In "Method B" I get an SQLException with a Timeout Errormessage.

Can somebody help me?

Thanks in advance.
 
Does it indicate what kind of timeout it is? Is it a timeout on the
transaction, or a timeout on the command?
 
It was a timeout on the SqlCommand object. I found out, that Sql-Server
can not handle nested transactions. The solution was to create an
SqlCommand object and bind a transaction to it. Then I assign the
SqlCommand object via reference to other methods where i can reuse the
object and in errorcase can rollback the transaction.

I just have to keep in mind to close the connection in the parent
method.

Thanks for all answers!

Greetings

Gerrit Horeis
 

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

Back
Top