i have done some thing similar see whether this approach helps you.
if you find a fall-backs please do point out.
this could help you are not stubborn in using classes for db wrappers
--> i have wrapped all my db related functions in a standard module.
--> i have methods like DBlogin, DBGetResults, DBExecSQL, DBExecSP
--> i have a private member in the module which will hold the connection
reference.
so in my vb project.
when ever i want to open a query result i just call like this
dim MyRs as recordset
blnCanProceed = DBGetReusult(MySql, MyRs)
so no need to for any gobal variables.
ok. if you want to share this dbconnection to other components
have two methods like
GetDbRefernce
SetDbRefrence
--
Cheers!!
--
At 07:28 AM 8/1/00 -0400, Steven Pospisil wrote:
>In Visual Basic I have 2 classes to handle the logging in, querying and
>retrieval of recordset rows from a database. The first class which is called
>"Login" stores the user name and password in private variables. It also
>stores
>the connection object (privately) called m_cn (as ADODB.Connection). I
>instanciate this class with the following in a bas module, "Public cn As New
>Login".
>
>The second class called "Query", executes a SQL statement that returns a
>recordset back to the user. The method that creates this recordset is called
>"fDoQuery" and it's code references the cn.Connection property of the "Login"
>class to get the current ADODB.Connection object of the current database I'm
>logged into as as shown below:
>
>rstQuery.Open "SELECT * FROM BANK", cn.Connection, adOpenKeyset,
>adLockPessimistic
>
>This way is fine for what I want, but it requires me to create a Public (or
>global) object of the Login class, in this case the cn object,
>which is then referenced within the "Query" class. Is there a better way of
>accessing the m_cn variable from withing the "Query" class
>other than using a global "Login" object?
>
>I've looked at the Implements keyword but I'm not sure how to use it in this
>case.
>
>Can you help?
>