Returning an object from a COM method call


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Returning an object from a COM method call

  1. #1
    Phil Guest

    Returning an object from a COM method call


    I have been tasked with creating a COM object that returns a connection object.
    Our management has some issues about handing out connection string info to
    a vast number of developers, many who should not have this level of DB access.
    They would like to have a COM object that developers could use that would
    hide the connection string info from developers, buto one that could be used
    like a regualr connection object within an ASP page or desktop app. I have
    never written a method that returns an object. I have done some experimenting
    and have gotten some clues, but no solution yet. Has anybody out there done
    anything like this? Thanks, Phil

  2. #2
    Darren Clark Guest

    Re: Returning an object from a COM method call

    Open vb and select activex dll
    set your project name and then your class name that you require

    then copy this code into your class

    Private m_connectionstring As String

    Public Function getConnection() As Variant
    Dim conn As ADODB.Connection
    Set conn = New Connection
    conn.ConnectionString = m_connectionstring
    conn.Open
    getConnection = conn
    End Function

    ASP can create the connection now by
    Dim oConn
    Set oConn = server.createObject("projectname.classname")


    You need still need to work out how you want to populate your connection
    string value....
    And the only thing to remember is that whenever you return anything to asp
    from com it must come as a variant as asp only understands varients.

    hope this help
    darren



    "Phil" <ptownsend@wvgot.org> wrote in message news:3d21bb20$1@10.1.10.29...
    >
    > I have been tasked with creating a COM object that returns a connection

    object.
    > Our management has some issues about handing out connection string info to
    > a vast number of developers, many who should not have this level of DB

    access.
    > They would like to have a COM object that developers could use that would
    > hide the connection string info from developers, buto one that could be

    used
    > like a regualr connection object within an ASP page or desktop app. I have
    > never written a method that returns an object. I have done some

    experimenting
    > and have gotten some clues, but no solution yet. Has anybody out there

    done
    > anything like this? Thanks, Phil




  3. #3
    Paul Clement Guest

    Re: Returning an object from a COM method call

    On 2 Jul 2002 07:39:28 -0800, "Phil" <ptownsend@wvgot.org> wrote:


    I have been tasked with creating a COM object that returns a connection object.
    Our management has some issues about handing out connection string info to
    a vast number of developers, many who should not have this level of DB access.
    They would like to have a COM object that developers could use that would
    hide the connection string info from developers, buto one that could be used
    like a regualr connection object within an ASP page or desktop app. I have
    never written a method that returns an object. I have done some experimenting
    and have gotten some clues, but no solution yet. Has anybody out there done
    anything like this? Thanks, Phil

    Connection objects are not typically passed around. It's a waste of database connection resources.

    It's preferable to establish and terminate your connection at the COM data tier level and return
    disconnected Recordsets instead.

    http://support.microsoft.com/default...;EN-US;q190717


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center