×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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 "authentication service is unknown"
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

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

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!

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


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.

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

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.

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

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 "New".

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

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.

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


Please make the distinction between a connection object and a connection string.

Tarek

The more I learn, the more I need to learn!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close