p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Professional (http://p2p.wrox.com/forumdisplay.php?f=57)
-   -   How to create OledbConnection Global.asax (http://p2p.wrox.com/showthread.php?t=13598)

EleaCarm May 31st, 2004 03:07 PM

How to create OledbConnection Global.asax
Hi, any know How to create OledbConnection instance?

This is my code:

void Application_Start(object sender, EventArgs e) {
OleDbConnection Application["ConnDB"] = new OleDbConnection ConfigurationSettings.AppSettings["strConnDB"]);

Thanks for a lot.

jacob May 31st, 2004 04:19 PM

OK, first of all you only have to post the question one time.

I do not know if you can do what you are trying, however I noticed a missing parenthesis...

new OleDbConnection(ConfigurationSettings.AppSettings["strConnDB"]);
What are you trying to accomplish by opening the connection here? It looks kind of odd to me, since I have learned that you should open the connection when needed.

Hope it helps :)


bmains May 31st, 2004 08:22 PM

You can create an object, and assign it to the application parameter:

OleDbConnection cn = New OleDbConnection(ConfigurationSettings.AppSettings["strConnDB"]);
Application["ConnDB"] = cn;

Then open and close the connection when needed.


All times are GMT -4. The time now is 12:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.