Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 3rd, 2004, 01:38 AM
Authorized User
 
Join Date: Feb 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple recordset or only one

Hi,

I have 2 different SQL in my ASP page. Should I create Recoedset object 2 different times like I am doing down. Or Should I just make Recordset object only once and use same for al the SQL statements, which one is right and efficient way ?

Thanks

******************
Set Conn=Server.CreateObject("ADODB.Connection")
Set rsEvents = server.CreateObject("ADODB.Recordset")

Conn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=AStrongSAPwd;Initial Catalog=matrimonialSQL;Data Source=irfan-ne8ldmk8y;Initial File Name=D:\Program Files\Microsoft SQL Server\MSSQL\Data\matrimonialSQL.mdf"
str = "Select profile_id from customer_profile where profile_id ='" & profileid & "'"

rsEvents.Open str, Conn
if rsEvents.EOF Then
profileidfound = "no"
else
profileidfound= "yes"

end if
set rsEvents=nothing

str=""
str = "Select email_address from customer_profile where email_address ='" & emailaddress & "'"

Set rsEvents1 = server.CreateObject("ADODB.Recordset")
rsEvents1.Open str, Conn

if rsEvents1.EOF Then
emailfound = "no"
else
emailfound= "yes"
end if

set rsEvents1=nothing

 
Old March 3rd, 2004, 10:36 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Unless you need to use both recordsets at the same time, there's little reason to use two different variables. I usually try to limit myself to a single recordset if possible just to save code. From a technical standpoint, I suppose it would be more efficient to use just one, because you skip having to instantiate a second object.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old March 3rd, 2004, 02:19 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

In your example? Just one recordset.
 
Old March 4th, 2004, 06:13 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliasp Send a message via Yahoo to aliasp
Default

I suggest to use a different recordsets in order to be far from some errors in running time,this way is more efficient to provide actions of each recordset from mixing.

ali
 
Old March 5th, 2004, 01:02 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry I didn't read the second statement correctly. I thought both were based on ProfileId. Answer is...separate recordsets.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Clone DAO Recordset into ADO Recordset kamrans74 VB How-To 0 March 6th, 2007 11:57 AM
listbox recordset multiple pages vaguy02 VBScript 1 June 21st, 2005 06:21 AM
ADODB.Recordset (0x800A0CB3)Current Recordset does tks_muthu Classic ASP Databases 0 June 16th, 2005 07:22 AM
Convert ADO recordset to DAO recordset andrew_taft Access 1 May 5th, 2004 02:31 PM
multiple recordset or only one isheikh All Other Wrox Books 0 February 15th, 2004 01:20 PM





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