Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Speed issue with VB6 / COM

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
0
0
US
Hi,

I have a COM .dll with a few classes that I'm using in a MTS package with my VB6 client user interface. This project used to run without COM & I've re-worked it to put all my SQL statements on the server (called from classes in the .dll).

My problem is, now that its running this way its working a whole lot slower, especially in the loading of some of the forms. What could this be from? The passing of recordsets over the network?? Just having to make to calls to the .dll?

Any help would be appreciated....
Thanks,
Ray
 
What kind of recordset are you passing? It should be an ADO Clientside recordset with the active connection set to nothing. Also, do not pass any other objects across process boundries (i.e. package to package) and do not pass them across the network. They will not be marshalled correctly and your app will slow down. The disconnected ADO recordset should marshal itself correctly. - Jeff Marler B-)
 
How does the syntax work for passing a disconnected recordset? I've tried a few different ways, and always get the error : #3705 "Operation is not allowed when the object is open."

Here's my .dll syntax:

Public Function LastNameCombo() As ADODB.Recordset

sqlstr = "SELECT LName, FName, EmployeeNumber from tblEmployees ORDER BY LName"

rs.Open sqlstr, DBConn, adOpenForwardOnly, adLockReadOnly

Set rs.ActiveConnection = Nothing
Set LastNameCombo = rs

End Function

Here's my client-side syntax:

Dim dbdll As MyDll.CEmpUpdates, rs2 As New ADODB.Recordset

Set dbdll = CreateObject("MyDll.CEmpUpdates")

Set rs2 = dbdll.LastNameCombo ' blows up here
Set rs2.ActiveConnection = HelpDeskConn

Maybe I'm just missing something; I'm pretty new at this stuff... Thanks for your help!!
 
We do this:
[tt]
With adoRS
.CursorType = adOpenForwardOnly
.LockType = adLockBatchOptimistic
End With

Set adoRS = adoComm.Execute()

Set adoRS.ActiveConnection = Nothing
Set adoComm = Nothing
[/tt]

Chip H.
 
Here's where I'm at with this process now; instead of passing recordsets from the server I'm loading the recordsets into arrays (datatype Variant) and passing the Variant.

The application still runs somewhat slower that before, when I test the time it takes various forms to load. Is this just to be expected since there are calls made to the .dll on the server???? Are there any tips on speeding things up while using COM/DCOM??

Thanks,
Ray
 
here are a few thoughts . . .

1) Do not pass objects (Client Side ADO recordsets are the exception)

2) Look out for repeated calls to COM servers in loops.

3) Pass everything ByVal

4) Do Not try to maintain state in MTS.

5) Do not try to store any objects in SPM.

6) Keep your DLLs lite and granular to avoid thread lock. - Jeff Marler B-)
 
Hey Jeff,

When you say "Do not pass objects (Client Side ADO recordsets are the exception)", what do you think about passing a variant that contains the data of a recordset? I'm doing this now and wonder if it has anything to do with performance loss that is taking place....
 
Variant arrays are fine and are one of the recommended approaches. Just be sure that you are only storing basic variable types (i.e. integer, string, long) inside of the array. - Jeff Marler B-)
 
well, I'm revisiting this project now, and in an effort to speed things up I included the .dll as a reference in the project, so it could run as part of the project and not remotely. Its still much slower than a version of the project (which we kept) that doesn't have functions contained in a .dll.

Has anyone else run into the problem with a project that uses an ActiveX .dll running slower than without? The app runs slow enough to make the change impractical....

Any ideas would be appreciated!
Thanks,
Ray
 
wrbodine -

Is your DLL raising any events to return an error status? That can slow things down because COM has to add additional marshalling code to handle it. Try to write your public methods to return a boolean for success/failure.

Chip H.
 
Thanks Chip,

Some of the methods do return boolean values for success/failure, but some return variant arrays containing recordset data. I think this is one of the main things slowing things up, but would still like to find a way to speed it up (while returning recordset data in calls to a .dll).

 
OK, as long as you aren't raising events across remote calls.

Have you thought about returning your recordsets as a string containing XML? It ought to be faster (even after loading up a DOM) because the marshalling for a string is much easier than a complex object like a recordset.

You'll need ADO 2.6 and MSXML 3.0 for this.

Chip H.
 
Hi All,

I am SORRY.

I would like to know when to Use COM and not to Use COM ?
Could anybody answer this silly question?

Is there any specific guidelines to be followed?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top