?
Solved

Call a function Open

Posted on 2001-06-08
5
Medium Priority
?
229 Views
Last Modified: 2010-05-02
Hi,

I am trying to create a class to wrap around an adodb recordset. I am trying to create a disconnected recordset. As a result, certain recordset commands (move next, etc) I want to pass to the recordset but other (open, etc) I want to handle myself. But anyways in terms of user friendliness I want to conform to the adodb recordset interface as much as possible. To do this I need to create a function called open. VB won't let me because open is a reserved word. Is there any way to get around this?

Zaphod.
0
Comment
Question by:Z_Beeblebrox
[X]
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
5 Comments
 
LVL 2

Expert Comment

by:kmv
ID: 6170537
You can create COM object in C/C++ which aggregate recordset object interfaces. I see that you have enouph experience for this.

Good luck!
0
 
LVL 7

Author Comment

by:Z_Beeblebrox
ID: 6171781
I want to write this in VB, not C++. Is there any way to create a class function called open in VB?

Zaphod.
0
 
LVL 2

Expert Comment

by:i_jester69
ID: 6172884
I know what you mean, but you are better off just naming your methods with descriptive(non-reserved) names like "OpenRecordset"
0
 
LVL 15

Accepted Solution

by:
ameba earned 0 total points
ID: 6174072
You can define interface IRecordset in type library, and then access your class clsRecorset via that interface.

' in clsRecordset
Implements IRecordset

' in your client's code:
    Dim rs As IRecordset
    Set rs = New clsRecordset
    rs.Open ...

' to create type library, you will need .IDL file, something like this
(I am not IDL expert, I copied this from Msado15.idl ;-))
// TypeLib : EX4.IDL (EX4)
// TargetFile : EX4.TLB

// UUID Usage:
// {3D6C1720-F527-11D3-A88C-ECBD3B289C70} : library EX4

[uuid(3D6C1720-F527-11D3-A88C-ECBD3B289C70),version(1.0),helpstring("Example 4 Library")]
library EX4
{
    importlib("STDOLE2.TLB");

    interface IRecordset;

    typedef [uuid(0000051B-0000-0010-8000-00AA006D2EA4)]
    enum {
        adOpenUnspecified = -1,
        adOpenForwardOnly = 0,
        adOpenKeyset = 1,
        adOpenDynamic = 2,
        adOpenStatic = 3
    } CursorTypeEnum;

    typedef [uuid(0000051D-0000-0010-8000-00AA006D2EA4)]
    enum {
        adLockUnspecified = -1,
        adLockReadOnly = 1,
        adLockPessimistic = 2,
        adLockOptimistic = 3,
        adLockBatchOptimistic = 4
    } LockTypeEnum;

    [
      odl,
      uuid(0000050E-0000-0010-8000-00AA006D2EA4),
      dual,
      nonextensible,
      oleautomation
    ]
    interface IRecordset : IUnknown {
        HRESULT _stdcall Move(
                        [in] long NumRecords,
                        [in, optional] VARIANT Start);
        [id(0x000003fa)]
        HRESULT _stdcall MoveNext();
        [id(0x000003fb)]
        HRESULT _stdcall MovePrevious();
        [id(0x000003fc)]
        HRESULT _stdcall MoveFirst();
        [id(0x000003fd)]
        HRESULT _stdcall MoveLast();
        [id(0x000003fe)]
        HRESULT _stdcall Open(
                        [in, optional] VARIANT Source,
                        [in, optional] VARIANT ActiveConnection,
                        [in, optional, defaultvalue(-1)] CursorTypeEnum CursorType,
                        [in, optional, defaultvalue(-1)] LockTypeEnum LockType,
                        [in, optional, defaultvalue(-1)] long Options);
        [id(0x000003ff)]
    };
}


Ref.:
IDL For VB Tutorial http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=130

Btw, it's easier to use word OpenRecordset.
0
 
LVL 7

Author Comment

by:Z_Beeblebrox
ID: 6211729
Seeing as how I accidentally posted this question for 0 points, I guess I'll just accept an answer rather than deleting the question.

Zaphod.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

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