Solved

Call a function Open

Posted on 2001-06-08
5
206 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

786 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