Wrox Programmer Forums
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 February 25th, 2005, 12:21 AM
Authorized User
 
Join Date: Feb 2005
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ashokparchuri Send a message via Yahoo to ashokparchuri
Default global.asax

hello,
can we connect to the database using global.asax file?i want to use the connection i gave in global.asax file rom all the pages in my aplication?please tell me how?in detail...

Thanks in advance-Ashok
 
Old February 25th, 2005, 08:40 AM
Authorized User
 
Join Date: Jan 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi, i suggest for your purpose to store the connection string in the wefconfig file like this:

<appSettings>
 <add key= "sqlconnection" value= "YOUR CONNECTION STRING HERE"></add>
</appSettings>

it is recommended to have one connection per page, so you have to give the connection string property to your connection in some way like this:
SqlConnection myConn = new SqlConnection (ConfigurationSettings.AppSettings["sqlconnection"]);

hope it helps...





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
Global.asax error sivaganesh_naidu ASP.NET 2.0 Professional 2 August 24th, 2006 10:53 AM
Error with Global.asax madkaikar_ashish .NET Web Services 3 August 7th, 2006 12:03 AM
what is global.asax? gaurav_jain2403 General .NET 1 February 3rd, 2006 02:40 PM





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