Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 31st, 2004, 03:07 PM
Registered User
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

Old May 31st, 2004, 04:19 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts

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 :)

Old May 31st, 2004, 08:22 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts

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.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
what is global.asax? gaurav_jain2403 General .NET 1 February 3rd, 2006 02:40 PM
global.asax ashokparchuri ADO.NET 1 February 25th, 2005 08:40 AM

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