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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is It possible to pass an ADODB.Connection as parameter?

Status
Not open for further replies.

Apinedo

Programmer
Oct 5, 2000
6
CO
Hi.
I'm new working with MTS and I have a problem.
I wrote the next code for a method of my MTS component in VB 6.0:
Public Function Validate_User(cn1 As Object) As Boolean
Validate_User = False
gsSqlStm = "Select * from table1"
Set mrsValidaUsuario = New ADODB.Recordset
mrsValidaUsuario.CursorType = adOpenForwardOnly
mrsValidaUsuario_Open gsSqlStm, cn1
....
....
Then, I tried to use its method on client-side writing the next lines of code:
Dim cn as new ADODB.Connection
cn.ConnectionTimeout = 100
cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = "SERVERNAME"
cn.Properties("Initial Catalog").Value = "DBNAME"
cn.Properties("User ID").Value = "sa"
cn.Properties("Password").Value = ""
cn.Open
Dim a As Object
Set a = CreateObject("SBCOMUserMTS.clsUsuario")
Dim b As Boolean
b = a.Validate_User(cn)<<<<<<HERE FAILS
I got a message &quot;authentication service is unknown&quot;
Is It possible to pass as an argument an ADODB.connection?
I know the component fails when it tries to open the ADODB.recordser mrsValidaUsuario
Thanks
 
Sir,
You must call SafeRef to pass a MTS object. But I cannot test ADO.ADOConnection.
I think it is not necessary to pass ADO.ADOConection as parameter.Because ADO should stay with your MTS components not with client side (thin client ^_^).

I hope you should understand it!

Regards! [sig][/sig]
 

You can pass a disconnected recordset back to client and that's a common strategy; however, I'm not so sure about passing connections!

If the idea is to have your MTS component read a set of records and pass them back to the client (as a recordset) then a disconnected recordset is what you're looking for. [sig][/sig]
 
im a new mts user, but i pas my connection to the object by setting a property i created in the object on the client to the connection string then using that property with an open in the component method, i used let and get. I think that is what you mean.
 
Hi.
Yes, it is ok to pass ADODB.Connection as parameter
Try to change your function to Validate_User(cn1 as ADODB.Connection). Notice: without &quot;New&quot;.

[sig][/sig]
 
In our development we have used a connection string to pass into the client and found that it is simple to use and pass around.

CVM, does passing the ADODB.Connection to the object as a parameter allow the MTS / COM+ services to use the Database connection pooling? Or does the connection just get passed inactive and recreated on the server?
The connection pooling is a great way of tubo-charging your app if it uses DB connections.

J.
 

Please make the distinction between a connection object and a connection string. [sig]<p> Tarek<br><a href= > </a><br>The more I learn, the more I need to learn![/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top