Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NiteShade
    wrote on last edited by
    #1

    I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew

    N C 2 Replies Last reply
    0
    • N NiteShade

      I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Have you tried debugging? Where is the error occuring?

      N 1 Reply Last reply
      0
      • N Not Active

        Have you tried debugging? Where is the error occuring?

        N Offline
        N Offline
        NiteShade
        wrote on last edited by
        #3

        yes, the error is occouring on cn.open (where cn is the set OdbcConnection). The following is the stack trace: [NullReferenceException: Object reference not set to an instance of an object.] System.Data.Common.Odbc32.SQLFreeHandle(Int16 HandleType, HandleRef StatementHandle) +0 System.Data.Odbc.DBCWrapper.CloseAndRelease() +191 System.Data.Odbc.OdbcConnection.DisposeClose() +311 System.Data.Odbc.OdbcConnection.Open() +638 Andrew

        N 1 Reply Last reply
        0
        • N NiteShade

          yes, the error is occouring on cn.open (where cn is the set OdbcConnection). The following is the stack trace: [NullReferenceException: Object reference not set to an instance of an object.] System.Data.Common.Odbc32.SQLFreeHandle(Int16 HandleType, HandleRef StatementHandle) +0 System.Data.Odbc.DBCWrapper.CloseAndRelease() +191 System.Data.Odbc.OdbcConnection.DisposeClose() +311 System.Data.Odbc.OdbcConnection.Open() +638 Andrew

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Good now look at the objects, which one is null? Are you sure that cn is valid?

          N 1 Reply Last reply
          0
          • N Not Active

            Good now look at the objects, which one is null? Are you sure that cn is valid?

            N Offline
            N Offline
            NiteShade
            wrote on last edited by
            #5

            It usually works... except on certain occasions. My best bet would be that the mySQL is not deallocation the connections in spite of me calling the close methods. Andrew

            1 Reply Last reply
            0
            • N NiteShade

              I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I don't see how an open or closed connection would make an object in your code null ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

              N 1 Reply Last reply
              0
              • C Christian Graus

                I don't see how an open or closed connection would make an object in your code null ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                N Offline
                N Offline
                NiteShade
                wrote on last edited by
                #7

                I'm starting to think that it may be a bug in mySQL or a microsoft program. Is there any way you can close all open connections to the database manually? Andrew

                C 1 Reply Last reply
                0
                • N NiteShade

                  I'm starting to think that it may be a bug in mySQL or a microsoft program. Is there any way you can close all open connections to the database manually? Andrew

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Yes, call sp_who, then KILL all the processes attached to your database ( thanks to whoever provided this solution, I asked this question only last week :-) ) Actually, that solves the problem in SQL Server. MySQL is kind of crap ( it doesn't even have stored procedures ), and in addition, sp_who is SQL Server specific, you'd need to find the equivelant in MySQL. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups