Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Call a function Open

Posted on 2001-06-08
5
Medium Priority
?
233 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses

618 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