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 October 10th, 2005, 04:17 PM
Registered User
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing the Server Database

 I'm new to ASP so hopefully my question is simple to answer. How many times can I access a database on the server in a single ASP/ADO web page? I have a validation page that accesses 2 different queries. The only way the code works is when I take one of the open connection statements off the page and only leave one of them. Hope this question makes sense.


Old October 10th, 2005, 06:35 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

;;;How many times can I access a database on the server in a single ASP/ADO web page?

As many times as you like. Generaly you connect, get your record sets (as many as you like) use the records then close your connection. Or you can place the records in an array using RS.getRows close your connection then use the arrays.

;;;Hope this question makes sense
Is a bit confusing. You only need to connect once on each page. Connect whwn you need records then close the connection when you have finished using the records.

How do I do it:
Function GetConnectionString()
   GetConnectionString = "Provider=SQLOLEDB.1; Password=localAdmin; Persist Security Info=True; User ID=sa; Initial Catalog=MHQohs; Data Source=LTJJ2571S;"
End Function

No when you want to open a connection call the function (once on each page you need it):
Set Conn = server.createobject("ADODB.Connection")

sql = "..."
set RS = conn.execute(sql)

sql = "..."
set RS2 = conn.execute(sql)

-----------page content use records---------

now when you have finished with your dynamic data:

   if isObject(RS) then set RS = nothing end if
   if isObject(RS2) then set RS2 = nothing end if
   set conn= nothing

Wind is your friend
Old October 13th, 2005, 08:29 AM
Registered User
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

If i interpret your Q correctly(one of the open connection statements), u can have only one OPEN CONNECTION statement for a databse connection. That is quite sufficient for as many times accessing the db.


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing database(enterprisedb) kanchuparthi.rams ADO.NET 2 June 10th, 2008 02:29 PM
Accessing Object of Database Sheraz Khan ASP.NET 2.0 Professional 0 August 27th, 2007 10:30 PM
Accessing the server Database dcarroll ASP.NET 2.0 Basics 1 October 10th, 2005 04:15 PM
Accessing sql server database trough vbs file vc1 VBScript 6 February 18th, 2005 09:54 AM

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