Problems with DB connection on ASP.NET 1.1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OmerCohen
    New Member
    • Mar 2009
    • 6

    Problems with DB connection on ASP.NET 1.1

    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
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    The first thing I'd suggest is to make sure that you have closed all database connections in your ASP.NET web application.

    Comment

    • OmerCohen
      New Member
      • Mar 2009
      • 6

      #3
      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?

      Comment

      • ericstein81
        New Member
        • Jul 2007
        • 14

        #4
        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.
        Code:
                Dim Conn As New OleDbConnection
        
                Dim connect As String
                connect = Application.StartupPath & "\login.mdb"
        
                Conn = New OleDbConnection(" connectionstring here ")
        also try setting the connection to = nothing after you do the close.
        Code:
        such as stream.close()
        stream = nothing
        Last edited by Frinavale; Mar 26 '09, 01:58 PM. Reason: Added [code] tags. Please post code in [code] [/code] tags.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Have you checked your windows event logs for any warning or error messages?

          Comment

          • OmerCohen
            New Member
            • Mar 2009
            • 6

            #6
            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

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Originally posted by OmerCohen
              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?

              Comment

              • OmerCohen
                New Member
                • Mar 2009
                • 6

                #8
                sure, but it's the same machine...
                both the IIS and SQL server runs on the same machine...

                Comment

                • OmerCohen
                  New Member
                  • Mar 2009
                  • 6

                  #9
                  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?

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    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.

                    Comment

                    • Frinavale
                      Recognized Expert Expert
                      • Oct 2006
                      • 9749

                      #11
                      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.

                      Comment

                      • OmerCohen
                        New Member
                        • Mar 2009
                        • 6

                        #12
                        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

                        Comment

                        Working...