Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple recordset or only one

Status
Not open for further replies.

inusrat

Programmer
Feb 28, 2004
308
0
0
CA
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 all 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
 
Thats fine, you can close the recordset instead of using nothing in the first instance. Also, there is no real need to create another recordset (rsEvents1) as once you close the other recordset you can reopen it using different SQL, on the same database connection.

Regards,


Lewis Harvey
lewis@lharvey.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top