Calling static functions without using New 
Author Message
 Calling static functions without using New

Hi

I am presently trying to implement a DLL which will intercept an
application's calls to DAO and redirect them to ADO.

For example, I would like to write my own DAO.Database and DAO.DBEngine
classes, remove a project's reference to the real DAO classes, and
replace it with my own. However, I've run into problems with the
following bit of code...

Sub DAOOpenJetDatabase()

 Dim db As DAO.Database
 Set db = DBEngine.OpenDatabase("C:\Nwind.mdb")
 db.Close

End Sub

When I try to write my own DBEngine class with an OpenDatabase
function, I always get the error "Object Required" on the OpenDatabase
call. I have been told that there is something "mysterious" about the
real DAO classes (and Microsoft classes in general) that this sort of
call will work with them but not with ones of my own creation.

Does anybody know how to write a class so that I can call static
members of my new class without having to recode my application (ie,
keep the code above exactly as it is) ?

Cheers,
Sean

* Sent from RemarQ http://www.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Mon, 01 Jul 2002 03:00:00 GMT  
 Calling static functions without using New
You need a class (say DAORoot) with Instancing set to GlobalMultiUse.
Then, add a public property Get called DBEngine that returns an
instance of your DBEngine replacement class.



Quote:
> Hi

> I am presently trying to implement a DLL which will intercept an
> application's calls to DAO and redirect them to ADO.

> For example, I would like to write my own DAO.Database and
DAO.DBEngine
> classes, remove a project's reference to the real DAO classes, and
> replace it with my own. However, I've run into problems with the
> following bit of code...

> Sub DAOOpenJetDatabase()

>  Dim db As DAO.Database
>  Set db = DBEngine.OpenDatabase("C:\Nwind.mdb")
>  db.Close

> End Sub

> When I try to write my own DBEngine class with an OpenDatabase
> function, I always get the error "Object Required" on the OpenDatabase
> call. I have been told that there is something "mysterious" about the
> real DAO classes (and Microsoft classes in general) that this sort of
> call will work with them but not with ones of my own creation.

> Does anybody know how to write a class so that I can call static
> members of my new class without having to recode my application (ie,
> keep the code above exactly as it is) ?

> Cheers,
> Sean

> * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
> The fastest and easiest way to search and participate in Usenet -
Free!

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 02 Jul 2002 03:00:00 GMT  
 Calling static functions without using New

Quote:

> Hi

> I am presently trying to implement a DLL which will intercept an
> application's calls to DAO and redirect them to ADO.

> For example, I would like to write my own DAO.Database and DAO.DBEngine
> classes, remove a project's reference to the real DAO classes, and
> replace it with my own. However, I've run into problems with the
> following bit of code...

> Sub DAOOpenJetDatabase()

>  Dim db As DAO.Database
>  Set db = DBEngine.OpenDatabase("C:\Nwind.mdb")
>  db.Close

> End Sub

1. You want to check all the uses of DAO in your application and think about
   strategies for implementing them in your library BEFORE starting to code
   your library. I can't stress this enough. You don't want to make unpleasant
   discoveries half-way through development.

2. I helped de-DAOize an application recently. Moving from DAO to RDO is a
   bit of work but DAO to ADO is likely to be simpler. In my subjective opinion,
   writing a DAO-to-ADO translation library is more costly in the long run than
   biting the bullet and converting the application.

--
MikeC

Please reply to the group.

  MikeC.vcf
< 1K Download


Tue, 02 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Call functions in static library

2. Calling functions in C++ static library

3. Accessing static (Shared) functions using this(Me).....in VB.NET

4. Reflection Question How to Call a Methode of a Member without Createing a new instance

5. Calling a sub or function using a variable through another sub or function

6. Log all events/function calls fired in vb6 without coding in each

7. Remove a function call without source code

8. Calling a DLL function without declaring it first

9. RAS: calling RasDial function without setting any EntryName

10. Function Call to Check for New Mail???

11. Writing and calling a function in a new frame

12. new thread for a specific function call or an entire object

 

 
Powered by phpBB® Forum Software