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
Solved

Call a function Open

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 65
Updates not working for MS Windows 7 12 181
Advice in Xamarin 21 97
Error with a code discussed on this page 5 32
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

829 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