Setting .ActiveConnection fails w/Com Services but works with REGSVR32

Posted on 2011-04-21
Last Modified: 2012-05-11

Microsoft says they won't support my question since VB6 is no longer supported, I'm re-posting a digest version of what I posted there with a bit more clarity. I'm hoping someone can make suggestions which can bail me out here without requiring me to re-code the entire application which was not mine to start with.
I'm currently in the process of migrating applications from a Windows 2000 server to a Server 2003 or 2008 system because of corporate mandate. Because of the number of changes between Server 2000 and Server 2008, I am opting to migrate only as far as 2003 at this point.

General Setup
Application uses a Classic ASP web-based front-end which instantiates VB6 DLL objects contained in an application-specific Component Services package which activates under the login context of a domain account. The DLLs connect to a SQL 2008 data source hosted on a Server 2008 system.

On our current Server 2000 system where the Classic ASP and Component Services is set up, all works fine. When attempting to set this up the same way on our Server 2003 system, a connection to the database will not work unless the DLL is activated outside of Component Services (i.e. Registered ONLY through REGSVR32). We cannot operate the data component outside of Component Services because some features need to use transactions and Component Service roles to function.

When the DLL is contained within a Component Services application, the following error occurs:

Err.number = 3001
Err.Source = ADODB.Command
Err.Description = Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Err.HelpContext = 1240641
Err.helpfile = C:\Windows\HELP\ADO270.CHM

When the DLL is registed by ONLY using REGSVR32 (and is not contained in Component Services), the above error does not occur.

Where Problems Occur
Below are relevant code snippets for both my calling Classic ASP page and the DLL's method code which is being executed. Bear in mind, setting the .ActiveConnection works when I register this using REGSVR32, but if I include this in a Component Services package, it fails.

Classic ASP code:
(Using double apostrophes in my VB code for comments in code below to preserve EE syntax hilighting)
Set Login = Server.CreateObject("MyLogin.NTLogin")  
'' Removed irrelevant Login object properties which are set...

Set cn = Server.CreateObject("ADODB.Connection")  
cn.ConnectionString = strMyConnectionString  

If Err.number <> 0 Then 
  Response.Write ("Error opening database")  
  '' In this ASP page, this is where things fail:  
  MyLogin.GetUserInfo cn  
End If

Open in new window

Affected DLL Object code (Found within MyLogin project, NTLogin module):
Public Sub GetUserInfo(ByVal cn As Variant)  
  '' (Irrelevant code removed)  
  Dim cmd As Command  

  Set cmd = New Command  
  With cmd  
      '' The next line is where it blows up (when in Component Services)  
      '' or works (when simply registered with REGSVR32):  
      .ActiveConnection = cn
      '' code at this point is not executed because it failed when setting 
      '' the Active Connection above.

Open in new window

Things I Have Tried
Thinking there may have been references to MDAC 2.5 which needed updating to MDAC 2.8, I recompiled the DLLs.
Component Services on my Server 2003 system have had COM Security set up to allow Access and Launch permissions for all accounts I'm using (both Classic ASP users, impersonated Component Service user)

Things I Know
When the DLL is in Component Services, no connection attempt is even made. When registed using REGSVR32, it does connect and retreive data. This was verified using SQL Server Profiler which I used to monitor all connection activity.
Failure happens when we set the .ActiveConnection to the Variant "cn" which is passed from ASP code.

Do you have any advice or suggestions? Am I missing something here?

Thank you!

Question by:tualchris
    LVL 1

    Author Comment


    If there are zones dedicated to COM+ or Component Services and IIS, I suppose this could be cross-posted there, otherwise I can't think of any other place.


    LVL 1

    Author Comment

    Thank you letenglandshake!  Let's see if this helps.

    LVL 1

    Accepted Solution

    I ended up resolving this be recompiling my DLL so that instead of having it receive an active connection from my ASP page, it would instead take a connection string and handle the database connection within the DLL.

    This is still a mystery as to why this behavior changed between Windows Server 2000 and Server 2003.  This worked, so that's all I need.

    Code modification looked something like this:

    Classic ASP Code:
    Set Login = Server.CreateObject("MyLogin.NTLogin")    
    MyLogin.GetUserInfo strMyConnectionString

    Open in new window

    LVL 1

    Author Closing Comment

    There was no answer as to why the same application would behave differently when migrated from Server 2000 to Server 2003.  I had hoped to find out there was a configuration issue or something I had to switch to make this work.  It appears the only option is to recode several Classic ASP pages and several DLLs.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now