damn messag"Timeout expired.The timeout period elapsed prior to completion of th

M

Meiny

When I'm Runung An insert Sql Stored procedure on SQL
SERVER after some seconds this message is handled.
I have tested this SP on Query Analyzer more and more,the
execution time in Query Analyzer is about 45 seconds.
But in my program , the progarm stop responding and then
this exception thrown.
the original message is:
"Timeout expired. The timeout period elapsed prior to
completion of the operation or the server is not
responding."
 
B

Bernie Yaeger

Hi Meiny,

Please post the sp - we would have a much better chance of helping you if
you do.

Bernie Yaeger
 
W

William Ryan

For a quick fix, you can adjust the Timeout property of your command object
to 60 seconds or however long you'll need --- The default value is 30
seconds, so if it takes 45 in QA, then this isn't surprising.

This will fix your immediate needs, but I'd seriously look at why a query is
taking 45 seconds. That's a long time and in most instances, users don't
want to wait that long. Even if you have it running in a background thread,
I'd look at an indexing strategy (although you want to do this with a trace
b/c Adding indexes can definitely speed up queries, but they need to be
thought out. After all, everything performance wise in a Database is a
tradeoff rather htan an either/or"

Anywya, try myCommand.CommandTimeout = 60 (or whatever number you know will
be enough for the query to finish)

Cheers,

Bill
 

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