VS 2010: SQL timeout exception, SQL Server executes normally
I faced with issues when in VS 2010 I 've got timeout exception, but in MS SQL Server it executes normally. The request is sproc that contains select statement with several joins. What reason, do you have any clues?
This happend to me once when I forgot to close the connection properly in one new routine that was called a lot.
When max connections was hit on the server, the program got timeout. But of course I could run the query in the query window that allready had a valid connection. Took a while to figure out..
Check activity monitor to see if you have a lots of connections from your client linger around, and if so, check that you close all connections properly.
This usually occurs when the database server does not respond in the default time limit. If you are trying to connect to a remote database location this situation is most probable due to inconsistent network connectivity.
Or this non-responsive behavior can also be caused when there is too much of precessing on the server side either because your query is too complex (having many joins and referencing many views and user-defined functions) or some maintenance operation is in progress on the server side (like database backup etc).
Also, please make sure your connection string has the connection timeout value set like this:
" server=myserver;database=myDatabase;uid=sa;pwd=pass;connection timeout=8; " here '8' seconds is used as a default timeout limit.
Another possible solution to this is setting the commandtimetout of command object.
idbcommand.CommandTimeout = 60000;