Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 March 1st, 2006, 07:43 AM
Authorized User
 
Join Date: Nov 2005
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
Default Is coded needed on every page?

Hi,

I have several ASp pages which need to call the SQL server.
Do I need to put on every ASP page the next code?

In the begin of the page:
===
Set conn = server.createobject("adodb.connection")
conn.open "DSN=FARMA"
set rs = server.createobject("adodb.recordset")
===


At the end after the SQL is executed
===
rs.Close
Conn.Close
Set rs=Nothing
Set Conn=Nothing
===

Or is it better to put it into an .INC file and just include it
in the beginning?

I am asking this because I have the code everytime I do an SQL sequence to get data from th DB, but I guess it is slowing down the speed of the pages when you want to see them, correct?

Please push me in the right direction,

David


 
Old March 1st, 2006, 06:53 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;Do I need to put on every ASP page the next code?
yes, on every page you need a connection. and yes if you open a connection you should close it when you have finished with it.

;;;Or is it better to put it into an .INC file and just include it
in the beginning
I place code in an include file that gets used in many places BUT more importantly code that you may want to change (has constants or variables etc) of course changing an incluse file changes it in all area were it is used - therefore yeah why not.

;;I am asking this because I have the code everytime I do an SQL sequence to get data from th DB
If you need a connection you need the connection code, so of course you are

;;but I guess it is slowing down the speed of the pages when you want to see them, correct?
No. weather the code is in an include file or in line its not going to effect your pages performance. As I said if you need a connection, you need the connection code.

HTH

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard coded paths pauliehaha Classic ASP Professional 8 February 6th, 2007 06:48 PM
Hard coded examples etrump BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 March 1st, 2006 02:10 PM
C# Help needed in aspx page savoym ASP.NET 1.0 and 1.1 Basics 3 January 28th, 2005 02:34 PM
The solution hard coded "ThePhile" jackchua BOOK: ASP.NET Website Programming Problem-Design-Solution 3 October 20th, 2004 11:25 PM





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