Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlConnection and Multiple Users

Status
Not open for further replies.

MJnaeblis

Programmer
Aug 14, 2002
19
US
Whenever I am using an SqlConnection object and one user has it open, a second user (on a different machine) produces an error saying the SqlConnection is already open.

I set a new instance of SqlConnection, open the connection on each page, and bring info from the DB. at the end of page_load i close the connection. if the second+ user(s) tries to load the page while the first user is still loading their page, all others get the error. I originally had this object at global level, but i have also tried it at session, page, and procedure level. even when declared and opened inside the page_load event, the variable seems to be shared by both users. is there a way to make the varible specific to the session or am i missing a property of the SqlConnection object or something? thanks.
 
well, i have noticed that it is not just the SqlConnection object. all variables seem to be shared by the users.

this time i set all SqlConnections to session variables. that worked fine, but now my SqlDataReaders are causing problems. It seems that when one user has finished with the database operation (which closes the Reader), another user gets a nullexception error because their Reader has been closed as well.

this just doesn't seem right. what am i doing wrong? is there a setting on the server machine that creates new instances of objects for each user or something?
 
Did you ever get your question answered?

Are you setting the session vars at the application level or the session level?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top