Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 December 1st, 2003, 11:32 PM
Authorized User
 
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default Replacing the #include for a connection object

Hi Everyone,

I have just started migrating from ASP to ASP+ and have just been leaning dbconnections. Im wondering how you go about creating a global connection object and including into the Pages you require it as #include is not support in the Page_Load sub.

eg. my connection code is:

Sub Page_Load
Dim objConn, DBComm, strSQL, DBRead
objConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=C:\Inetpub\wwwroot\ASPTutorials\TestCode\da tabase\Clients.mdb")
objConn.Open()
End Sub

What is the replacement for the in ASP.NET

Thanks Tim

TDA
__________________
TDA
 
Old December 2nd, 2003, 04:00 AM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are more solutions, but this is the one I use:
Create a key in the <appSettings> part of the web.Config file.
<add key="connection" value="Data Source= ;user id= ;password= ; initial catalog= " />

Then assign this value to a variable in your page:
string connection=System.Configuration.ConfigurationSetti ngs.AppSettings["connection"];

Regards,

Gerhard Wentink
 
Old December 2nd, 2003, 04:10 AM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I used a Sql server connection in my former post. You will have to replace it with a OLEDB connection,

Regards,

Gerhard Wentink





Similar Threads
Thread Thread Starter Forum Replies Last Post
setup database connection include file in PHP crmpicco PHP Databases 2 September 30th, 2007 04:18 PM
Replacing Database connection upon login rsasuncion1010 ASP.NET 2.0 Basics 0 March 28th, 2007 01:09 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
Connection string and file include trouble cramerjj Classic ASP Databases 2 February 26th, 2005 04:46 AM
Connection Object shahchi1 ADO.NET 5 June 1st, 2004 11:48 PM





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