ADO object as a parameter 
Author Message
 ADO object as a parameter

Hi,

What I try to achieve is calling a DLL which would use the connection from
the calling
application.
I used a connection object as a parameter and it is transferred to the class
with no problem.
Public Sub mySub(MyConn As ADODB.Connection)
    Set myGlobalConn = MyConn

But when I try to use the connection either in a command
Set myCommand.ActiveConnection = myGlobalConn

or in a recordset open method
myRec.Open "Select * From myTable", myGlobalConn , .....

I get an error message: "Arguments are of wrong type, are out of the
acceptable range or are in conflict with one another"
even though myGlobalConn  has the right connection string.
Can someone tell me what is missing?
Thanks
Doru Roman



Sun, 13 Jul 2003 02:07:33 GMT  
 ADO object as a parameter
Not assuming the obvious, did you open the connection string inside your class
module before using it in the recordset?
Quote:
-----Original Message-----

Hi,

What I try to achieve is calling a DLL which would use the connection from
the calling
application.
I used a connection object as a parameter and it is transferred to the class
with no problem.
Public Sub mySub(MyConn As ADODB.Connection)
    Set myGlobalConn = MyConn

But when I try to use the connection either in a command
Set myCommand.ActiveConnection = myGlobalConn

or in a recordset open method
myRec.Open "Select * From myTable", myGlobalConn , .....

I get an error message: "Arguments are of wrong type, are out of the
acceptable range or are in conflict with one another"
even though myGlobalConn  has the right connection string.
Can someone tell me what is missing?
Thanks
Doru Roman

.



Sun, 13 Jul 2003 05:18:53 GMT  
 ADO object as a parameter
Marie,

The connection is opened in the calling application, and then the object
that contains the class is created.
Then a subroutine which is part of the object's class is called:
Dim myConnection As New ADODB.Connection
myConnection.Open ".........."
Set x = CreateObject(myDLL.myClass)
    x.mySub myConnection     ' calls the DLL's subroutine with the open
connection as a parameter

So the connection is opened in the calling application, it transfers all
right to the DLL.
I know that because I can use myConnection.Execute("Select * From Table1")
successfully.
But if I try to use it in a Command object or trying to open a recordset
with the connection
it generates the error:
Set myCommand.ActiveConnection = myGlobalConn     - ERROR
myRec.Open "Select * From myTable", myGlobalConn , .....  - ERROR
So the connection seems OK except for some instances.

Doru Roman


Not assuming the obvious, did you open the connection string inside your
class
module before using it in the recordset?

Quote:
-----Original Message-----

Hi,

What I try to achieve is calling a DLL which would use the connection from
the calling
application.
I used a connection object as a parameter and it is transferred to the class
with no problem.
Public Sub mySub(MyConn As ADODB.Connection)
    Set myGlobalConn = MyConn

But when I try to use the connection either in a command
Set myCommand.ActiveConnection = myGlobalConn

or in a recordset open method
myRec.Open "Select * From myTable", myGlobalConn , .....

I get an error message: "Arguments are of wrong type, are out of the
acceptable range or are in conflict with one another"
even though myGlobalConn  has the right connection string.
Can someone tell me what is missing?
Thanks
Doru Roman

.



Sun, 13 Jul 2003 05:49:25 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ADO Parameter Object

2. How to create a parameter field in Command object (ADO/VB 6.0)

3. Profiler repeats 1st SP call only with ADO parameter objects

4. Oracle, ADO Command object and Parameter fields

5. Problem passing ADO command objects as parameters in MTS

6. How are ADO parameter objects stored?

7. Problem passing ADO command objects as parameters in MTS

8. Calling a vbs with a parameter,the Parameter is a object

9. COM-Object in ASP with COM-Object as parameter

10. COM-Object in ASP with COM-Object as Parameter

11. ADO Command Object using Multiple Connection Objects

12. ADO Control OR ADO object?

 

 
Powered by phpBB® Forum Software