473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

.Close, = Nothing - Real dumb question? with a real quick answer...

Hi, I feel a little dumb for asking this (considering im writing
TSQL) but there doesn't seem to be any definitive answers on the
search engines...

Okay I understand that if you open the ADO connection that you
close it with:

adoCon.Close
Set adoCon = Nothing

and if you open a recordset like below:

Set rsBlockedCheck = Server.CreateObject("ADODB.Recordset")
strSQL = "EXECUTE pmUserIsBlocked @lngLoggedInUserID = " &
lngLoggedInUserID &", @lngToUserID = " & lngToUserID
rsBlockedCheck.Open strSQL, strCon

you close it with...

rsBlockedCheck.Close
Set rsBlockedCheck = Nothing

My question is do you need to close and set nothing to the
strSQL like:

strSQL.Close
Set strSQL = Nothing

Personally, i'd go for you don't and that only the connection
and the recordset need closed... is this right? and - are the
.close required for the connection and recordset or do you just
set the = Nothing ?

Regards

----------------------------------------------
Posted with NewsLeecher v2.0 Beta 5
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

Jul 22 '05 #1
2 2253
InvisibleMan wrote:
Hi, I feel a little dumb for asking this (considering im writing
TSQL) but there doesn't seem to be any definitive answers on the
search engines...

Okay I understand that if you open the ADO connection that you
close it with:

adoCon.Close
Set adoCon = Nothing

and if you open a recordset like below:

Set rsBlockedCheck = Server.CreateObject("ADODB.Recordset")
strSQL = "EXECUTE pmUserIsBlocked @lngLoggedInUserID = " &
lngLoggedInUserID &", @lngToUserID = " & lngToUserID
rsBlockedCheck.Open strSQL, strCon

you close it with...

rsBlockedCheck.Close
Set rsBlockedCheck = Nothing

My question is do you need to close and set nothing to the
strSQL like:

strSQL.Close
Set strSQL = Nothing
No. strSQL is not an object. Only oblject variables created using the Set
keyword can be set to Nothing. Not all objects provide a Close method, but
when they do, it should be used.

Personally, i'd go for you don't and that only the connection
and the recordset need closed... is this right?
right
and - are the
close required for the connection and recordset or do you just
set the = Nothing ?

both.

Using Close allows the objects to release resources they use gracefully,
eliminating references to other objects you wish to close and destroy.

---------------------------------------------------------------------------------------------------
Personally, I would not use a connection string to open your recordset
(doing so can turn off connection pooling, which can create performance
problems if you're lucky, server crashes if you're not lucky). Instead,
create an explicit connection object which you use for all data access on
the page.

Set cn = server.createobject("adodb.connection")
cn.open strCon

'open a no-default recordset
Set rsBlockedCheck = Server.CreateObject("ADODB.Recordset")
rsBlockedCheck.CursorLocation=adUseClient
rsBlockedCheck.Open strSQL, cn,,,1

'or open the default cursor like this:
set rs=cn.Execute(strSQL,,1) 'CreateObject is not necessary
'always tell ADO the command type: 1 = adCmdText

Close and destroy the connection as soon as you are finished using it, in
order to release the connection to the pool for another thread on your
server to use

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2
Thanks Bob that was really help in more ways than one...
Much appreciated - thanks for taking the time

----------------------------------------------
Posted with NewsLeecher v2.0 Beta 5
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Healey | last post by:
I'm trying to craft a search that capitalizes letters depending on their context, specifically after a space or the beginning of a string. For example I'd like to turn the quick brown fox...
7
by: Willem van Rumpt | last post by:
Hi all, coming from an unmanaged programming background, I took my time to sort out the IDisposable and finalizer patterns. Just when I thought I had it all conceptually neatly arranged, the...
3
by: Shelby | last post by:
Hi, I still fail to properly end a function call with the below codes. How can I terminate all function calls? -------------------------------------------------------------- Connect.vb...
8
by: Paul W | last post by:
Hi - in an asp.net application, how should I close out a sqlclient.connection? What combination and order of Conn.close conn.dispose conn=nothing Should I use? Specifically, is the...
3
by: Robin Tucker | last post by:
Should I consider this to work in other locales? If theServer.Name <> "(local)" and theServer.Name <> "(localhost)" Then ' Can only use local machine in this version..... End If
7
by: Joel Hedlund | last post by:
Hi! There's one thing about dictionaries and __hash__() methods that puzzle me. I have a class with several data members, one of which is 'name' (a str). I would like to store several of these...
1
by: DILA | last post by:
Hi, I have included an embedded Real Player and an embedded Quick Time Player for streaming videos, in my web pages. I'm interested in searching for a method or a script to disable the...
3
by: homec | last post by:
Hi, I have included an embedded Real Player and an embedded Quick Time Player for streaming videos, in my web pages. I'm interested in searching for a method or a script to disable the ...
7
by: Robert | last post by:
Thanks George, I really am grateful for attempts to be helpful, but this really doesn't answer the question in my OP. What I am looking for is an explanation of WHY things are this way (I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.