arthurh88
asked on
Dim a variable accross all my ASP.NET pages?
I have an ASP.NET application with about 20 webforms.
I created Class1.vb, and in this class I have this:
Public Shared MSSQLCommand As Data.SqlClient.SqlCommand
Public Shared MSSQLConnection As New Data.SqlClient.SqlConnecti on
And in all of my webforms, I have this code:
Class1.MSSQLConnection.Con nectionStr ing = ConfigurationManager.Conne ctionStrin gs("DataCo nnection") .Connectio nString
This is causing all kinds of problems, giving errors saying a "connection is string is open" when multiple users access the pages at the same time.
The only other thing I know to do is delcare MSSQLConnection as private on all of my forms. I'd much rather delcare them once and reference them. Is there another way I can do this? I like having code that uses as little repetition as possible...it sems that if I add a
"Private MSSQLConnection as New Data.SqlClient.SqlConnecti on" at the top of all of my web forms, that I'm being inefficient...or is that the only way to do this?
I created Class1.vb, and in this class I have this:
Public Shared MSSQLCommand As Data.SqlClient.SqlCommand
Public Shared MSSQLConnection As New Data.SqlClient.SqlConnecti
And in all of my webforms, I have this code:
Class1.MSSQLConnection.Con
This is causing all kinds of problems, giving errors saying a "connection is string is open" when multiple users access the pages at the same time.
The only other thing I know to do is delcare MSSQLConnection as private on all of my forms. I'd much rather delcare them once and reference them. Is there another way I can do this? I like having code that uses as little repetition as possible...it sems that if I add a
"Private MSSQLConnection as New Data.SqlClient.SqlConnecti
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER