Question on ADODB.Connection with VB6

Posted on 2005-03-11
Medium Priority
Last Modified: 2010-05-02

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

Question by:TungVan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

by:Steve Sirica
ID: 13520446
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 ""
LVL 66

Expert Comment

by:Jim Horn
ID: 13520621
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.

Expert Comment

by:Steve Sirica
ID: 13520690
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.
LVL 12

Accepted Solution

Bob Lamberson earned 120 total points
ID: 13523214
> 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.


Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question