general questions: best practices

M

Mike

Well OKAY you got me. I never use CreateObject for recordsets!

:-((

Ray,

I bet my dog could take your cats

Mike
 
M

middletree

A local high school here has the nickname "the Bearcats" Some sort of weird
genetic experiment, I figure.
 
A

Aaron Bertrand - MVP

I did write "owner" at first, but then deleted it. I was listening to the
slavery story on NPR this morning on the way to work, and I didn't want to
mis-speak about my cats.

So you'd rather portray images of beastiality? :-0
 
A

Aaron Bertrand - MVP

Never thought of that. Is that really an issue for an Intranet, though?

Not all foobars like that are malicious. You also need to protect yourself
from the boneheads with errant copy & pastes, etc. And we *know* we all
have those people within our intranets. :)
 
P

Phillip Windell

I have 5. That's about all the neighbors can handle. It had
something to do with their flower beds but I always ignore them when
they are in one of those moods.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
M

middletree

Good point. Thanks.


Aaron Bertrand - MVP said:
Not all foobars like that are malicious. You also need to protect yourself
from the boneheads with errant copy & pastes, etc. And we *know* we all
have those people within our intranets. :)
 
P

Phillip Windell

Ray at said:
No way man. My one cat is one 16 pound muscle with legs, and he can kick
ass on anything!

One of the neighbors has a huge black one that got in my house. It and
mine had a debate about the situation that I tried to interveine with
and simply put the neighbor's cat outside. The thing chomped down on
my hand and I think it went clear to the bone. As it scambled past me,
feet and claws everywhere, I realized how important is was for me to
not be without a shirt (as I wasn't). I look like I crashed into a
barb-wire fence. I ended up at the doctor's office over that one and
the hand just got nimble enought to type yesterday.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
M

Mike

Whenever I see a neighbors cat in one of my flower beds I turn my dog loose.
I imagine some cats are still running.


Mike


Phillip Windell said:
I have 5. That's about all the neighbors can handle. It had
something to do with their flower beds but I always ignore them when
they are in one of those moods.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com

Ray at said:
echo middletree>>C:\vendetta.log

Ray at work, father to seven cats
 
P

Phillip Windell

Well, If I ever find someone's dog jambed halfway through my cats' Pet
Door I'll let the cats deal with what is left hanging out.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com

Mike said:
Whenever I see a neighbors cat in one of my flower beds I turn my dog loose.
I imagine some cats are still running.


Mike


Phillip Windell said:
I have 5. That's about all the neighbors can handle. It had
something to do with their flower beds but I always ignore them when
they are in one of those moods.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com

Ray at said:
Well, I can always choose the pdf over the cat.

echo middletree>>C:\vendetta.log

Ray at work, father to seven cats
 
R

Ray at

Man, be careful!!!! I hope the cat's okay too.

Okay, no need for anyone to yell about off-topic posts. That's all. :]

Ray at work
 
B

Bob Barrows

middletree said:
I really don't understand the above too well, but I'll keep digesting
it.
OK, let me try again. Let's illustrate what happens when you execute these
two lines of code:

Set rs = server.createobject("adodb.recordset")
'ADO creates a closed recordset object and points rs at it

Set rs = conn.execute(strSQL)
'ADO creates a Command object which does the following 3
'things:
' 1. executes strSQL
' 2. creates a new, open recordset object to receive the results

'At this point, there are two recordset objects in memory: the one
'created by the createobject statement, and at which rs is still
'pointing, and the new one which was just created by the Command
'object

' 3. points rs at the new recordset

'So now rs is pointing at the new recordset. Now, there is no longer
'any variable pointing at the original, still-closed recordset, and so,
'it is released from memory

To sum up, when you use createobject("adodb.recordset") followed by
connection.execute (or command.execute) you have wound up creating two
recordset objects when you only intended to create one.

Is this a big deal? Not really. The initial recordset, with no Field objects
in its Fields collection, has a relatively small footprint in memory, is
created very quickly, and does not stay there very long. Still:

Best practice is to skip the createobject statement when using Execute to
retrieve data into a recordset.

Is that better?
Bob Barrows
 
M

middletree

Makes sense. I will hold on to this.

Thanks


Bob Barrows said:
OK, let me try again. Let's illustrate what happens when you execute these
two lines of code:

Set rs = server.createobject("adodb.recordset")
'ADO creates a closed recordset object and points rs at it

Set rs = conn.execute(strSQL)
'ADO creates a Command object which does the following 3
'things:
' 1. executes strSQL
' 2. creates a new, open recordset object to receive the results

'At this point, there are two recordset objects in memory: the one
'created by the createobject statement, and at which rs is still
'pointing, and the new one which was just created by the Command
'object

' 3. points rs at the new recordset

'So now rs is pointing at the new recordset. Now, there is no longer
'any variable pointing at the original, still-closed recordset, and so,
'it is released from memory

To sum up, when you use createobject("adodb.recordset") followed by
connection.execute (or command.execute) you have wound up creating two
recordset objects when you only intended to create one.

Is this a big deal? Not really. The initial recordset, with no Field objects
in its Fields collection, has a relatively small footprint in memory, is
created very quickly, and does not stay there very long. Still:

Best practice is to skip the createobject statement when using Execute to
retrieve data into a recordset.

Is that better?
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top