Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
isheikh
Starting Member
25 Posts |
Posted - 2004-02-15 : 12:07:22
|
Hi,I have 2 different SQL statments in my ASP page. Should I create Recordset 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, Connif rsEvents.EOF Then profileidfound = "no"else profileidfound= "yes" end ifset rsEvents=nothingstr=""str = "Select email_address from customer_profile where email_address ='" & emailaddress & "'"Set rsEvents1 = server.CreateObject("ADODB.Recordset")rsEvents1.Open str, Connif rsEvents1.EOF Then emailfound = "no"else emailfound= "yes"end ifset rsEvents1=nothing |
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2004-02-15 : 17:43:27
|
Using one is fine. But, it's good practice to close them before you set them to nothing. ESPECIALLY with connection objects.I recently worked on a system were the connection was being set to nothing but not closed. It wasn't an issue on development or test environments, but when we put it live, connections were being orphaned faster than they were being cleaned up. It brought everything to a grinding halt.Damian |
 |
|
|
|
|