-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks