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!

Why are my variables being shared?

Status
Not open for further replies.

MJnaeblis

Programmer
Aug 14, 2002
19
US
I have posted this question in the VB.NET forum, but I suppose it really belongs here.

I first had my SqlConnection object as a public variable. When two users tried to do database operations at the same time, one would get an error saying the connection is already open. I have tried putting the SqlConnection object at page level (with Dim) and then at procedure level (with Dim). At both of these levels, the same error was received. I recently tried setting a session object to the SqlConnection object and opened the session object instead. While I did not get an error that the connection was already open, I did get an error that the SqlDataReader had been closed on the second user while it was still reading (obviously from the first user getting done first and closing that reader). The reader is still declared at page level with Dim.

Is Dim on any level considered a shared variable? What do I need to do to make my variables unique instances to each user?
 
Are you sure all declarations for when the connection was a public variable have been destroyed?

Sounds like something's still lingering somewhere.

D
 
no, it only happens when they go at the same time. like if two people on two different machines hit the save button that does a DB operation at the same time, one of them gets the error.
also the objects are no longer public. they are declared at page level with only Dim.

to me, this just sounds glitchy. has anyone else come across this?
 
Post the code. I don't see how this would have happened, unless you are confusing an Application object with a public variable.



Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top