Solved

COM+ question

Posted on 2002-07-02
8
222 Views
Last Modified: 2010-05-02
I have a ActiveX dll installed on a remote server which I am using to connect to SQL Server and access data, passing back to a client app.  When the dll calls the connect function, it appears that it is still the client machine that is connecting to SQL Server, not the dll.  How do I configure it so the transaction server/COM+ server handles the connection and data access rather than the client PC?
0
Comment
Question by:Joeharvey
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:rpai
Comment Utility
Your client app would be instanciating the Activex DLL which in would establish the connection to the Server. The client would use the type library or custom proxy-stub DLL on the client to use your server application remotely.
0
 
LVL 3

Author Comment

by:Joeharvey
Comment Utility
I'm not sure what you mean.  What needs to be done in order for the server(middle-tier) to make the actual database connection and return the result set to the client?  Or is this not possible?
0
 
LVL 18

Expert Comment

by:mdougan
Comment Utility
Well, a couple of things.  First, your COM+ component should be handling all of the ADO calls to open the connection and recordsets etc.  I'd suggest that each method call to the component calls to open the connection and then closes the connection on the way out.  This may sound like a lot of overhead, but I think that connection pooling keeps the overhead down.  On the plus side, it forces you to design Stateless components which is much better for scaleability.

Your code should look pretty normal in the COM+ component.

In the Client, you should be sure to use CreateObject to instantiate your middle-tier component.  I think if you use New, then this invokes the COM interface and not the COM+ interface.  So, if you have a local version of the DLL (which is likely if you are working on your development machine), using New will run the local DLL as opposed to the remote one.

Last thought, you should try not to pass a recordset as in input parm to your middle-tier component.  Passing recordsets across processes has a huge overhead, and, what happens is that the COM+ component really just gets a copy of the recordset anyway (and it's not really a complete copy of the recordset, just the data without all of the property settings of things like .RecordCount, .Filter etc.)

You can return a recordset as the return value of a function, and your client should be able to use it correctly, but this is still somewhat inefficient.  We used to convert the recordset to XML using the Recordset Save option into a Microsoft DOM object, and then would send the DOM object's XML back to the client.  This was very fast.  Then, on the client, you can reload the XML into a recordset if you want, or load it into a DOM and use that to process the data.....
0
 
LVL 3

Author Comment

by:Joeharvey
Comment Utility
mdougan,

  I was creating the component on the client using NEW.  I will try using the CreateObject and let you know what happens.  Thanks for the info.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Author Comment

by:Joeharvey
Comment Utility
After installing the DLL on the server, and distributing it to a client pc, I used CreateObject to instantiate the component.  It is still creating the connection from the client pc.  Is there something inside of the dll that I am missing here?  No matter what I try I still get the connection coming from the client.
0
 
LVL 5

Expert Comment

by:rpai
Comment Utility
I believe the only place you have the code to establish a Database connection is in the DLL component. Is that right?

Now the way COM+ works is, whenever the client app instanciates the Remote DLL (using CreateObject), there is a proxy object (of the DLL on the remote server) created on the client machine. The client would use the type library or custom proxy-stub DLL on the client to establish the DB Connection. (You can imagine as a image of the DLL object being created on the client machine). My guess is, that is the reason why it appears as if the connection is being made by the client.
0
 
LVL 3

Author Comment

by:Joeharvey
Comment Utility
You are correct rpai.  The only code to make the db connection is in the class.  (Connecting to a SQL Server database).

When I launch the client app, I can go into SQL Server and look at the current connections.  When doing so, I see that the connection (Host name) is coming from the client pc.  


0
 
LVL 5

Accepted Solution

by:
rpai earned 150 total points
Comment Utility
Yes, because it is the client app that is requesting the DB connection. But the actual DB connection is done by the DLL component.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

11 Experts available now in Live!

Get 1:1 Help Now