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

Posted on 2011-04-21
Medium Priority
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
  • 4

Author Comment

ID: 35467635

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.



Author Comment

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


Accepted Solution

tualchris earned 0 total points
ID: 35694014
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


Author Closing Comment

ID: 35694056
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.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

830 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