Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 2nd, 2003, 01:16 AM
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 Replace #include in ASP.NET

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 3rd, 2003, 09:44 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could create a connection class, wherein one of the methods was something like DBconnect() that executes the code you described. You would just call that method in your Page_Load event.

I suggest that you store your connection string in a globally accessible location, such as the web.config file.

 
Old December 8th, 2003, 05:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

At the end of your web.config file enter this:

</system.web>
    <appSettings>
        <add key="you_name_it"
         value="Provider=Microsoft.Jet.OLEDB.4.0; data source=C:/DB/db_here.mdb" />
    </appSettings>
</configuration>

Then you can use this code:
Dim strConn As String = ConfigurationSettings.AppSettings("you_name_it")
 
Old December 8th, 2003, 05:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Oh and BTW, you might want to change your connection.inc to connection.asp

.inc files can be viewed in a web browser as plain text. with the asp extension it gets sent to the asp.dll file and nothing gets returned to the browser/hacker.

 
Old December 8th, 2003, 06:44 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

Ohhh. Thats not good at all. Thanks i will change that.

Tim :)

TDA





Similar Threads
Thread Thread Starter Forum Replies Last Post
include style in asp.net Magen ASP.NET 1.0 and 1.1 Basics 3 February 26th, 2007 07:14 PM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
Using Include statements in ASP.NET acorbo ASP.NET 1.0 and 1.1 Basics 3 June 28th, 2005 08:36 AM





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