Connecting Tech Pros Worldwide Help | Site Map

Problems with DB connection on ASP.NET 1.1

Newbie
 
Join Date: Mar 2009
Posts: 6
#1: Mar 25 '09
Hey Dudes
I'm having a wierd problem creating a DB connection on a ASP.NET 1.1 web app.
Once every few days the Connection.Open() function just freezes till it gets a timeout, and from that moment and on every attempt to create a db connection from the application gets the same result until I restart the IIS service, but I can still connect to the same DB from a winforms app, using the exact same connection string. I'm using ASP.NET 1.1 over a windows 2003 server machine with a quad-core CPU, and SQL server 2000 on the same machine (connection is local).
any ideas, anyone?
Thanks,
Omer
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#2: Mar 25 '09

re: Problems with DB connection on ASP.NET 1.1


The first thing I'd suggest is to make sure that you have closed all database connections in your ASP.NET web application.
Newbie
 
Join Date: Mar 2009
Posts: 6
#3: Mar 26 '09

re: Problems with DB connection on ASP.NET 1.1


Thanks, but I've already done that... I work in a disconnected model, I just open the connection when I need something, and then close it right away...
or is there something I didn't think of?
Newbie
 
Join Date: Jul 2007
Posts: 14
#4: Mar 26 '09

re: Problems with DB connection on ASP.NET 1.1


Make sure that you are declaring a new instance of the DB connection. It may be hanging up because it is still open even though you are telling it to close. I was having a similar problem before.
Expand|Select|Wrap|Line Numbers
  1.         Dim Conn As New OleDbConnection
  2.  
  3.         Dim connect As String
  4.         connect = Application.StartupPath & "\login.mdb"
  5.  
  6.         Conn = New OleDbConnection(" connectionstring here ")
  7.  
also try setting the connection to = nothing after you do the close.
Expand|Select|Wrap|Line Numbers
  1. such as stream.close()
  2. stream = nothing
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#5: Mar 26 '09

re: Problems with DB connection on ASP.NET 1.1


Have you checked your windows event logs for any warning or error messages?
Newbie
 
Join Date: Mar 2009
Posts: 6
#6: Mar 29 '09

re: Problems with DB connection on ASP.NET 1.1


ericstein81: thanks dude, I'll try that
Frinavale: I checked, there's nothing weird there... I bet it's the IIS side, but when I'll try what ericstein81 suggested I'll be wiser, or at least less stupid ;-)
Thanks again dudes
Omer
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#7: Mar 30 '09

re: Problems with DB connection on ASP.NET 1.1


Quote:

Originally Posted by OmerCohen View Post

Frinavale: I bet it's the IIS side,

That's what I meant.
Did you check the Windows event logs on the computer hosting the server?
Newbie
 
Join Date: Mar 2009
Posts: 6
#8: Mar 31 '09

re: Problems with DB connection on ASP.NET 1.1


sure, but it's the same machine...
both the IIS and SQL server runs on the same machine...
Newbie
 
Join Date: Mar 2009
Posts: 6
#9: Apr 22 '09

re: Problems with DB connection on ASP.NET 1.1


Well, I tried to create a new connection object every time I connect to the database, it just made things worse... :-S
any ideas? anyone?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,706
#10: Apr 22 '09

re: Problems with DB connection on ASP.NET 1.1


This looks like a classic situation of resources being tied up and left useless on the server.

As far as I can tell, this can happen in one of two ways :
  1. Connections are not being closed before they are requested again.
  2. Connections are allowed to lie idle for long enough that further communication is not recognised as valid. Maybe a timeout occurs on one side alone.
Notwithstanding that you say this has been handled correctly, it seems to me that this is indeed the cause of your problem Omer.

I'm afraid that I can't help in .NET at all, but hopefully this gives you the opportunity to look at this again with the understanding that the problem is there, even if not easily visible.

Good luck with your project.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#11: Apr 22 '09

re: Problems with DB connection on ASP.NET 1.1


Have you checked all Exception cases to make sure that connections are closed if something goes wrong?

One other thing I just thought of, have you tried releasing the resources by calling the Dispose() method? It should be called when your Objects are disposed but if you are overwriting the deconstructor or finalize method then you may not be releasing your resources correctly.

Be sure that you aren't going to use the resource any more before calling this method.
Newbie
 
Join Date: Mar 2009
Posts: 6
#12: Apr 23 '09

re: Problems with DB connection on ASP.NET 1.1


Thanks dudes..
I tried killing the connection completely (with dispose and assigning to nothing), but it only got worse, as I said...
the web application uses a DAL component, the same component used by a parallel winforms application, and on the winforms version it doesn't cause any problems...
after I started killing the connection within the DAL after every DB operation the problem started accuring every few hours, and before that it was every few days, so I switched back to the old DAL.
anyway, I guess it's some wierd network thing, so I'll be thanking you all for your help and throw it back to the customer's system administrator... ;-)
Omer
Reply