How to reference a connection established on an ASP page from a COM object 
Author Message
 How to reference a connection established on an ASP page from a COM object

We have a simple ASP page that establishes a connection with the following
code.

<%
dim DataConn
If IsObject(Session("conn")) Then
   Set DataConn = Session("conn")
Else
   Set DataConn = Server.CreateObject("ADODB.Connection")
   DataConn.ConnectionTimeout = Session("DataConn_ConnectionTimeout")
   DataConn.CommandTimeout = Session("DataConn_CommandTimeout")
   DataConn.Open Session("DataConn_ConnectionString"),
Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
   Set Session("conn") = DataConn
End if
%>

We then instantiate a simple COM object that builds an HTML (SELECT) combo
box with the following code:

<%
   dim objCB
   set objCB = server.CreateObject("BISCommon.cboCommon")
   objCB.Generic "cboCounty", "BIS_LIB", "MT_COUNTY", "PK_COUNTY", "NAME",
"PK_COUNTY", 250, "*LAST", "SV_Code" , "SV_Desc"
%>

Question: How do we reference a connection established on the ASP page from
within the COM object?

The code works great when we establish the connection inside the COM object
but we want to use the connection already established by the ASP page.  We
assume this will be more effiecient with IIS 4.0.  We are NOT using MTS,
therefore, no connection pooling.

Many thanks in advance.

Keith A. Rowe
President
===========================================
Cornerstone Software Services, Inc.
A Microsoft Certified Solution Provider  (850) 514-3060

===========================================



Sun, 01 Jun 2003 02:41:49 GMT  
 How to reference a connection established on an ASP page from a COM object

Quote:
> We have a simple ASP page that establishes a connection with the following
> code.

you've simplified that code for readabilty, right?
you aren't really storing a connection in the session object?

Quote:
> We then instantiate a simple COM object that builds an HTML (SELECT) combo
> box with the following code:
> <%
>    dim objCB
>    set objCB = server.CreateObject("BISCommon.cboCommon")
>    objCB.Generic "cboCounty", "BIS_LIB", "MT_COUNTY", "PK_COUNTY", "NAME",
> "PK_COUNTY", 250, "*LAST", "SV_Code" , "SV_Desc"
> %>

> Question: How do we reference a connection established on the ASP page
from
> within the COM object?

is there something wrong with passing the connection as a paramter to the
Generic method, or having a public connection property on the cboCommon
object which you set before calling Generic?

Quote:
> The code works great when we establish the connection inside the COM
object
> but we want to use the connection already established by the ASP page.  We
> assume this will be more effiecient with IIS 4.0.  We are NOT using MTS,
> therefore, no connection pooling.



Sun, 01 Jun 2003 19:24:08 GMT  
 How to reference a connection established on an ASP page from a COM object
see [[[[KEITH]]] below...


Quote:
> > We have a simple ASP page that establishes a connection with the
following
> > code.

> you've simplified that code for readabilty, right?
[[[[KEITH]]] yes
> you aren't really storing a connection in the session object?

[[[[KEITH]]] oh yes, I do not like it but client insists it is a standard
practice.
Quote:

> > We then instantiate a simple COM object that builds an HTML (SELECT)
combo
> > box with the following code:

> > <%
> >    dim objCB
> >    set objCB = server.CreateObject("BISCommon.cboCommon")
> >    objCB.Generic "cboCounty", "BIS_LIB", "MT_COUNTY", "PK_COUNTY",
"NAME",
> > "PK_COUNTY", 250, "*LAST", "SV_Code" , "SV_Desc"
> > %>

> > Question: How do we reference a connection established on the ASP page
> from
> > within the COM object?

> is there something wrong with passing the connection as a paramter to the
> Generic method, or having a public connection property on the cboCommon
> object which you set before calling Generic?

[[[[KEITH]]] Not sure what you mean by passing the connection.  If you mean
passing the connection string that will not work in our app since several
blocks of script code depend on the connection in the inline page.  We are
just trying to re-use the connection that is already established.  The name
of the connection is "DataConn".  Can I simply pass it as a parm?


Mon, 02 Jun 2003 02:07:09 GMT  
 How to reference a connection established on an ASP page from a COM object
oooh, B A D design

use con pooling! it has nothing to do with MTS!

it comes  with MDAC 2.x or ODBC 3.x



Quote:
> We have a simple ASP page that establishes a connection with the following
> code.

> <%
> dim DataConn
> If IsObject(Session("conn")) Then
>    Set DataConn = Session("conn")
> Else
>    Set DataConn = Server.CreateObject("ADODB.Connection")
>    DataConn.ConnectionTimeout = Session("DataConn_ConnectionTimeout")
>    DataConn.CommandTimeout = Session("DataConn_CommandTimeout")
>    DataConn.Open Session("DataConn_ConnectionString"),
> Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
>    Set Session("conn") = DataConn
> End if
> %>

> We then instantiate a simple COM object that builds an HTML (SELECT) combo
> box with the following code:

> <%
>    dim objCB
>    set objCB = server.CreateObject("BISCommon.cboCommon")
>    objCB.Generic "cboCounty", "BIS_LIB", "MT_COUNTY", "PK_COUNTY", "NAME",
> "PK_COUNTY", 250, "*LAST", "SV_Code" , "SV_Desc"
> %>

> Question: How do we reference a connection established on the ASP page
from
> within the COM object?

> The code works great when we establish the connection inside the COM
object
> but we want to use the connection already established by the ASP page.  We
> assume this will be more effiecient with IIS 4.0.  We are NOT using MTS,
> therefore, no connection pooling.

> Many thanks in advance.

> Keith A. Rowe
> President
> ===========================================
> Cornerstone Software Services, Inc.
> A Microsoft Certified Solution Provider  (850) 514-3060

> ===========================================



Sun, 01 Jun 2003 05:41:02 GMT  
 How to reference a connection established on an ASP page from a COM object

I know that in Com+ you could use ObjectContext for this.  Maybe one of the
old COM gurus here would know:  Was there a precursor to ObjectContext?

Good luck,
Ian


Quote:
> see [[[[KEITH]]] below...



> > > We have a simple ASP page that establishes a connection with the
> following
> > > code.

> > you've simplified that code for readabilty, right?
> [[[[KEITH]]] yes
> > you aren't really storing a connection in the session object?
> [[[[KEITH]]] oh yes, I do not like it but client insists it is a standard
> practice.

> > > We then instantiate a simple COM object that builds an HTML (SELECT)
> combo
> > > box with the following code:

> > > <%
> > >    dim objCB
> > >    set objCB = server.CreateObject("BISCommon.cboCommon")
> > >    objCB.Generic "cboCounty", "BIS_LIB", "MT_COUNTY", "PK_COUNTY",
> "NAME",
> > > "PK_COUNTY", 250, "*LAST", "SV_Code" , "SV_Desc"
> > > %>

> > > Question: How do we reference a connection established on the ASP page
> > from
> > > within the COM object?

> > is there something wrong with passing the connection as a paramter to
the
> > Generic method, or having a public connection property on the cboCommon
> > object which you set before calling Generic?
> [[[[KEITH]]] Not sure what you mean by passing the connection.  If you
mean
> passing the connection string that will not work in our app since several
> blocks of script code depend on the connection in the inline page.  We are
> just trying to re-use the connection that is already established.  The
name
> of the connection is "DataConn".  Can I simply pass it as a parm?



Mon, 02 Jun 2003 09:54:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How do we reference a connection established on the ASP page from within the COM object?

2. Reference to com object lost after Page_load completes on web page

3. COM-Object in ASP with COM-Object as parameter

4. COM-Object in ASP with COM-Object as Parameter

5. com object will not read registry when com object called from asp (vb works fine)

6. IIS4 No Longer Shows Error Messages In ASP Pages or COM Objects

7. C++ COM Object in ASP Page

8. Passing a collection object to a COM server from an ASP page

9. IIS4 No Longer Shows Error Messages In ASP Pages or COM Objects

10. Performance of ASP pages calling COM object methods

11. Passing an Array from a COM Object to an ASP Page

12. Passing Object Ref from asp page to com

 

 
Powered by phpBB® Forum Software