Enlightened
New member
Hi,
I am sorry if you think this is easy to google. I have been googling for hours and can't figure this out. I have my SQL Server connected to my visual studio ASP.net C# application, and I have a connection in the web.config file. Then I create a connection in every page like this:
SqlConnection myConnection = new SqlConnection("my stuff");
That works fine. I can do everything I need with that. But, I have so many pages, I don't want to put that at the top of every page because eveyr page uses queries and stuff. Is there anyone in ASP 2.0 where I can put that connection string so I do it only once, like put it in the global file, or my masterpage behind code? I tried doing that, but none of the pages can then reference that connection so I can use it to write quries. Or is putting that connection at the top of every page my only option? I tried putting it in the session part of gobal file, but didn't work.
Any help will be great. Thank you.
I am sorry if you think this is easy to google. I have been googling for hours and can't figure this out. I have my SQL Server connected to my visual studio ASP.net C# application, and I have a connection in the web.config file. Then I create a connection in every page like this:
SqlConnection myConnection = new SqlConnection("my stuff");
That works fine. I can do everything I need with that. But, I have so many pages, I don't want to put that at the top of every page because eveyr page uses queries and stuff. Is there anyone in ASP 2.0 where I can put that connection string so I do it only once, like put it in the global file, or my masterpage behind code? I tried doing that, but none of the pages can then reference that connection so I can use it to write quries. Or is putting that connection at the top of every page my only option? I tried putting it in the session part of gobal file, but didn't work.
Any help will be great. Thank you.