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
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?
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?
RE: Is It possible to pass an ADODB.Connection as parameter?
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?
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!