Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 132
  • Last Modified:

Question on ADODB.Connection with VB6

Hi,

I created a variable called:

Private mConnection As ADODB.Connection


At some point of my debugging process, sometimes I see that

mConnection = ""

and sometimes

mConnection = Nothing


I know what nothing is, but is there a difference btw mConnection = "" and mConnection = Nothing



Thx
0
TungVan
Asked:
TungVan
  • 2
1 Solution
 
Steve SiricaSenior Web Application EngineerCommented:
I don't hink it takes some one from mensa to say "Yep, sure looks different to me."

I'll be nothing until it's initialized by say something like
set mConnection = new adodb.connection
at that point you will begin to see it as ""
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Since mConnection is an Object, clearing it is done by Set mConnection = Nothing.  Setting it to an empty string might just be sloppy work on the previous developer's part.
0
 
Steve SiricaSenior Web Application EngineerCommented:
jim I don't think Tung is setting the connection object to a connection string I think they were just illustrating it's value while looking at it at a certain poink.
0
 
Bob LambersonSoftware EngineerCommented:
> Private mConnection As ADODB.Connection
only declares a memory variable that can reference an object, in this case an ADODB.Connection object.

Set mConnection .............. actually creates the object and sets a pointer to the address of that object.

Private mConnection As New ADODB.Connection    also creates the object and sets the pointer
                                   ^^^^^^

Set mConnection = Nothing removes the reference to the created object and returns the memory occupied by it, to the pool.

mConnection = "" does not return the memory to the memory pool until vb does it automatically when the object is out of scope and there are no references to it.

Bob
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now