[AccessD] Using Global Connctions

Mark L. Breen subs at solution-providers.ie
Fri Mar 14 11:38:01 CST 2003


Hello All,

I was not aware that a previous debate (sounds a little heated) had been
already carried out.  Sorry for duplicating the discussion.

In the last few emails, Marcus was the only one that explicitly stated that
he likes the idea of using Globals for a db connection.

So leaving aside passing around an order nunber or a customer id as a global
(which I would never even consider), what do you guys do to hand around a
database connection?  Do you use Globals or do you make the connction each
time or do you use some kind of class.  Any sample code would be interesting
to read.

What I do is have the following code in a module

' This will be the global connection that we will share, we open it once
only and share it throughout the applications life
Global gccnn As New ADODB.Connection
Global Const gcstrConStr As String = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=spps40;Data
Source=PC1"


and then in the first form_load I have

    ' Give it a connect string
    gccnn.ConnectionString = gcstrConStr

    ' And make the connection
    gccnn.Open



What do you guys think of this strategy, should I use a class to pass it
around.  And if I am not using a class, do you think that it is a little bit
untidy or is downright bad practice.

Again, I am just curious what the rest of the world is doing in their apps.

Thanks

Mark





More information about the AccessD mailing list