Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am working on vb.net Desktop application. I am running a query to fetch data from database. When there are too many data rows, then it executes that query for the first time. on executing it for the second time, it gives me an error
The underlying connection was closed: An unexpected error occurred on a receive.

How can I execute that query more than once? I am using web service.

Thanks in advance.

Mrunal
Posted
Updated 6-Apr-12 0:05am
v2
Comments
ZurdoDev 6-Apr-12 7:59am    
You need to share your code so we can help.
Shahin Khorshidnia 6-Apr-12 9:10am    
And the code?

1 solution

VB
Protected Overrides Function GetWebRequest(uri As Uri) As WebRequest
	Dim myWebRequest As HttpWebRequest = DirectCast(MyBase.GetWebRequest(uri), HttpWebRequest)
	myWebRequest.KeepAlive = False
	Return myWebRequest 
End Function


And Look at this:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;915599[^]
 
Share this answer
 
v3
Comments
MacParekh 7-Apr-12 2:52am    
Hi Shahin

Thanks for your reply.
Actually my application is desktop so there is no web.config or Http request.
there is app.config in my application.

My query returns 50k+ rows. whenever there is less count of rows application is working fine. but when large amount of rows comes at that time this type of error occurs.

Any Other solution

Thank You
Shahin Khorshidnia 7-Apr-12 4:53am    
Does your application is accessing directly to database?
You told that you where using web service. So you must override GetWebRequest in your webservice.
Look at this please:
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.getwebrequest.aspx
MacParekh 7-Apr-12 6:12am    
Dear Shalin,
I have faced same problem in web application. I already solved it as u told. I have updated webconfig. and updated maxhttprequest value.

Now Problem is that.. I am using web service in desktop as class file...It is installed in local machine. So there is no http connection occur.

Thanks
Shahin Khorshidnia 7-Apr-12 8:47am    
So, we must see the code as ryanb31 and I said before!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900