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. Help - Connection objects.

Help - Connection objects.

Scheduled Pinned Locked Moved ASP.NET
helpdatabasequestion
2 Posts 2 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.
  • M Offline
    M Offline
    MrMickeyDeeGimp
    wrote on last edited by
    #1

    Hi I am currently working on an application where we have a set of classes which handle SQL DB calls. I import all of these obects into my code as static objects. I then call functions in the classes, which will in turn open a db connection, do read/write, and then close the connection. I am getting an object set to null reference exception if more than one person is using the application at once. They appear to be sharing the connection object, as the error always occurs on the 'conn.Close()' (conn being my connection object) for the function whic finishes last. I take it that the first finished function is closeing the second functions connection? Question is.... How am I going to fix this? If anyone has any suggestions, please help. Thanks

    S 1 Reply Last reply
    0
    • M MrMickeyDeeGimp

      Hi I am currently working on an application where we have a set of classes which handle SQL DB calls. I import all of these obects into my code as static objects. I then call functions in the classes, which will in turn open a db connection, do read/write, and then close the connection. I am getting an object set to null reference exception if more than one person is using the application at once. They appear to be sharing the connection object, as the error always occurs on the 'conn.Close()' (conn being my connection object) for the function whic finishes last. I take it that the first finished function is closeing the second functions connection? Question is.... How am I going to fix this? If anyone has any suggestions, please help. Thanks

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      It sounds like your evaluation of the problem is correct. Try creating instances of the connection classes just before you use them, rather than keeping a single shared instance.


      my blog

      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