Sqlcommand object gives command timeout

G

Guest

Hi,

I am using sqlcommand object to execute a stored procedure. And i populate a dataset fro sqldataadapter. When i run it for the first time it works fine when try to go to the next page it gives the following error

Error Message :Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

i tried giving commandtimeout=0 and also increased the timeout period but still it doesnot work

Give me a solution..

Regards
Yaseen
 
M

Miha Markic [MVP C#]

Hi Yaseen,

This error normally occurs when you are not closing connections.
Do you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Yaseen D M said:
Hi,

I am using sqlcommand object to execute a stored procedure. And i populate
a dataset fro sqldataadapter. When i run it for the first time it works fine
when try to go to the next page it gives the following error
Error Message :Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached.
 
F

Frans Bouma [C# MVP]

Yaseen said:
Hi,

I am using sqlcommand object to execute a stored procedure. And i populate
a dataset fro sqldataadapter. When i run it for the first time it works
fine when try to go to the next page it gives the following error

Error Message :Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached.

i tried giving commandtimeout=0 and also increased the timeout period but
still it doesnot work

Give me a solution..

Well, if you run into a poolsize limit, you should check your application:
do you keep open connections around? You could also increase the pool size
however that would only postpone the same error.

Frans.
 
G

Guest

Hi,

Yes i am closing the connections. and in table i have 102 records but it brings 100 records from that table.

Thank u
Yaseen

Miha Markic said:
Hi Yaseen,

This error normally occurs when you are not closing connections.
Do you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Yaseen D M said:
Hi,

I am using sqlcommand object to execute a stored procedure. And i populate
a dataset fro sqldataadapter. When i run it for the first time it works fine
when try to go to the next page it gives the following error
Error Message :Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached.
i tried giving commandtimeout=0 and also increased the timeout period but still it doesnot work

Give me a solution..

Regards
Yaseen
 
M

M. Zeeshan Mustafa

Hi Yaseen,

Try increasing Max Pool property of connection pooling, for
reference see this link:
http://msdn.microsoft.com/library/e...ntSqlConnectionClassConnectionStringTopic.asp

If you are using a data reader, its very important to close datareader
and connection after you're done, if you dont, connection will
go orphan!

--
Hope this helps,
Zeeshan Mustafa, MCSD


Yaseen D M said:
Hi,

Yes i am closing the connections. and in table i have 102 records but it
brings 100 records from that table.
Thank u
Yaseen

Miha Markic said:
Hi Yaseen,

This error normally occurs when you are not closing connections.
Do you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Yaseen D M said:
Hi,

I am using sqlcommand object to execute a stored procedure. And i
populate
a dataset fro sqldataadapter. When i run it for the first time it works fine
when try to go to the next page it gives the following error
Error Message :Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all
pooled connections were in use and max pool size was reached.
i tried giving commandtimeout=0 and also increased the timeout period
but
still it doesnot work
Give me a solution..

Regards
Yaseen
 
W

William Ryan eMVP

In addition to verifying that all of the connections are closed you may
want to do a few other things. There are two timeouts, Connectino Timeouts
and Command Timeouts. I think the problem is with the Connection and based
on the error message, this is probably it. I'd say definitely it but there
can be more than one thing wrong. Also, even on the command side, setting it
to 0 isn't reliable. You can only change the connection timeout via the
connection string but you may want to bump that up. As the others have
mentioned, verifying that the connections are closed and changing to pool
size are the first two things I'd do.

For testing purposes I often have needed to trap the State_Changed event of
the connection . I didn't really 'need' to do this, but I was convinced one
time that my connectinos were all closing and this helped me find out that
they weren't. I had a class library and down in the recesses of it, there
was a try/catch block eating the exception but the exception was fired
before close was getting called. The exception happened intermittently so
it obscured this - it was a tiny oversight code wise but it had pretty big
ramifications.

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
M. Zeeshan Mustafa said:
Hi Yaseen,

Try increasing Max Pool property of connection pooling, for
reference see this link:
http://msdn.microsoft.com/library/e...ntSqlConnectionClassConnectionStringTopic.asp

If you are using a data reader, its very important to close datareader
and connection after you're done, if you dont, connection will
go orphan!

--
Hope this helps,
Zeeshan Mustafa, MCSD


Yaseen D M said:
Hi,

Yes i am closing the connections. and in table i have 102 records but it
brings 100 records from that table.
Thank u
Yaseen

Miha Markic said:
Hi Yaseen,

This error normally occurs when you are not closing connections.
Do you?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Hi,

I am using sqlcommand object to execute a stored procedure. And i populate
a dataset fro sqldataadapter. When i run it for the first time it
works
period
 

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