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