Connection time out

  • Thread starter Thread starter João Santa Bárbara
  • Start date Start date
J

João Santa Bárbara

Hi all
i´m opening a table with a few thousands of records and it allways gets me a
connection timeout.
my connection string is ( using sqlclient.sqlconnection and a
SqlDatadapter)
"User ID=sa;Initial Catalog=BD;Data Source=Server;Password =xxxx;Connect
Timeout=30000"

can someone help ..

JSB
 
Joao:

Where is the exception being thrown? If you are calling .Fill on the
adapter and not opening it yourself, it does both Open the connection and
executing the query and it's probably the Command Timing out. Either way
something is wrong.. but if the connection is timing out, record size isn't
the issue. To test this, manually open and close the connection right
before and after your call to fill and trap a SqlException for both Open and
fill. You may have a bad connection string

If it's the command, you have a different issue. I've pulled over a few
hundred thousand records before (never do this for any reason other than
intentional stress testing or idle curiousite) and did it in under 3
minutes. The query itself should be happening instantaneously but since
it's shoving all the data back over when you call fill, there can be a
lapse.

I think the Command is the likely cause of this problem so you may want to
manipulate its TimeOut property instead of the Connections to see if this
resolves it. But usually there's smoke where there's fire and if your query
is taking more than a few seconds to fire, you'll probably need to end up
restructuring it.


HTH,

Bill

www.devbuzz.com
www.knowdotnet.com
 
Back
Top