Problem passing ADO command objects as parameters in MTS 
Author Message
 Problem passing ADO command objects as parameters in MTS

Brief description of problem:
Win NT 4.0, VB6, latest service packs. ADO 2.5

I've declared an ADO command object in one method of a class in an MTS
package. The command object is used to call a SQL Server stored procedure.
It has several parameters (added using .Type, .Direction .Size, .Append as
normal)
Once I've set all the parameters, I pass this command object to a procedure
in a different MTS package.
eg:

In calling class:
Dim cmdTest as ADODB.command
Dim Ret as Boolean

set cmdTest = new ADODB.command
<set parameters>

Ret = myclass.execSP(cmdTest)
etc

and in myclass:
Public Function execSP (mySP as ADODB.command) as Boolean

<Get DB Connection>

<Perform logging etc>

<Execute stored proc>

End Function

However, as soon as I set the ActiveConnection property of the Command
object in the execSP function, I get:

Runtime error '3001':
The application is using arguments that are of the wrong type, are out of
acceptable range, or are in conflict with one another.

I know this is not actually the case, because when I run *exactly* the same
code outside MTS, it works fine. Also, when I move execSP to be private to
the calling class, it also works fine.

It seems like there is a problem with MTS and passing the ADO command object
reference.
I have tried passing the reference ByVal and ByRef, neither work.
I've tried moving the DLL that contains myclass to the same package that the
calling function inhabits, but it still doesn't work (I did this as I
thought it might have something to do with activity boundaries?)
Incidently, I'm creating myclass using the recommended "GetObjectContext()"
syntax.

Has anybody had similar problems?
Or has anybody got any suggestions?

Thanks in advance for any help.

Stu



Sat, 27 Dec 2003 04:08:30 GMT  
 Problem passing ADO command objects as parameters in MTS
Hi Stu.

I think you've encountered a problem with state.  I would venture a guess
that the stateful command object you passed to your MTS server component did
not maintain its property values set in the MTS client object.  As a result,
when your MTS server component tries to access the some of the passed
command object's stateful properties, an error occurs  For Example, if
you've set the activeconnection property in your MTS client component before
you passed it to your MTS server component, I would almost bet that your
problem lies there because I don't think that the MTS server component can
access the activeconnecton object's properties.  The fact that you do not
encounter this difficulty when using the components outside of MTS, I think,
lends some credence to that theory.

Perhaps, you could try creating your command object within the context of
your MTS server component rather than your MTS client component to see if
that method works.

Just a guess.

--
HTH

Craig Hunt, MCSE, MCDBA
AISA Logic, Inc.
http://aisalogic.com

--Think when you breathe.


Quote:
> Brief description of problem:
> Win NT 4.0, VB6, latest service packs. ADO 2.5

> I've declared an ADO command object in one method of a class in an MTS
> package. The command object is used to call a SQL Server stored procedure.
> It has several parameters (added using .Type, .Direction .Size, .Append as
> normal)
> Once I've set all the parameters, I pass this command object to a
procedure
> in a different MTS package.
> eg:

> In calling class:
> Dim cmdTest as ADODB.command
> Dim Ret as Boolean

> set cmdTest = new ADODB.command
> <set parameters>

> Ret = myclass.execSP(cmdTest)
> etc

> and in myclass:
> Public Function execSP (mySP as ADODB.command) as Boolean

> <Get DB Connection>

> <Perform logging etc>

> <Execute stored proc>

> End Function

> However, as soon as I set the ActiveConnection property of the Command
> object in the execSP function, I get:

> Runtime error '3001':
> The application is using arguments that are of the wrong type, are out of
> acceptable range, or are in conflict with one another.

> I know this is not actually the case, because when I run *exactly* the
same
> code outside MTS, it works fine. Also, when I move execSP to be private to
> the calling class, it also works fine.

> It seems like there is a problem with MTS and passing the ADO command
object
> reference.
> I have tried passing the reference ByVal and ByRef, neither work.
> I've tried moving the DLL that contains myclass to the same package that
the
> calling function inhabits, but it still doesn't work (I did this as I
> thought it might have something to do with activity boundaries?)
> Incidently, I'm creating myclass using the recommended

"GetObjectContext()"

- Show quoted text -

Quote:
> syntax.

> Has anybody had similar problems?
> Or has anybody got any suggestions?

> Thanks in advance for any help.

> Stu



Sun, 28 Dec 2003 23:16:13 GMT  
 Problem passing ADO command objects as parameters in MTS
Craig,

Thanks for that - I think you're on the right tracks - I've been digging
through MSDN, and remember seeing something about MTS having problems with
maintaining the state of certain ADO objects...

However, I've managed a workaround, and whilst it's not the most elegant
solution in the world, works fine!

Stu


Quote:
> Hi Stu.

> I think you've encountered a problem with state.  I would venture a guess
> that the stateful command object you passed to your MTS server component
did
> not maintain its property values set in the MTS client object.  As a
result,
> when your MTS server component tries to access the some of the passed
> command object's stateful properties, an error occurs  For Example, if
> you've set the activeconnection property in your MTS client component
before
> you passed it to your MTS server component, I would almost bet that your
> problem lies there because I don't think that the MTS server component can
> access the activeconnecton object's properties.  The fact that you do not
> encounter this difficulty when using the components outside of MTS, I
think,
> lends some credence to that theory.

> Perhaps, you could try creating your command object within the context of
> your MTS server component rather than your MTS client component to see if
> that method works.

> Just a guess.

> --
> HTH

> Craig Hunt, MCSE, MCDBA
> AISA Logic, Inc.
> http://aisalogic.com

> --Think when you breathe.



> > Brief description of problem:
> > Win NT 4.0, VB6, latest service packs. ADO 2.5

> > I've declared an ADO command object in one method of a class in an MTS
> > package. The command object is used to call a SQL Server stored
procedure.
> > It has several parameters (added using .Type, .Direction .Size, .Append
as
> > normal)
> > Once I've set all the parameters, I pass this command object to a
> procedure
> > in a different MTS package.
> > eg:

> > In calling class:
> > Dim cmdTest as ADODB.command
> > Dim Ret as Boolean

> > set cmdTest = new ADODB.command
> > <set parameters>

> > Ret = myclass.execSP(cmdTest)
> > etc

> > and in myclass:
> > Public Function execSP (mySP as ADODB.command) as Boolean

> > <Get DB Connection>

> > <Perform logging etc>

> > <Execute stored proc>

> > End Function

> > However, as soon as I set the ActiveConnection property of the Command
> > object in the execSP function, I get:

> > Runtime error '3001':
> > The application is using arguments that are of the wrong type, are out
of
> > acceptable range, or are in conflict with one another.

> > I know this is not actually the case, because when I run *exactly* the
> same
> > code outside MTS, it works fine. Also, when I move execSP to be private
to
> > the calling class, it also works fine.

> > It seems like there is a problem with MTS and passing the ADO command
> object
> > reference.
> > I have tried passing the reference ByVal and ByRef, neither work.
> > I've tried moving the DLL that contains myclass to the same package that
> the
> > calling function inhabits, but it still doesn't work (I did this as I
> > thought it might have something to do with activity boundaries?)
> > Incidently, I'm creating myclass using the recommended
> "GetObjectContext()"
> > syntax.

> > Has anybody had similar problems?
> > Or has anybody got any suggestions?

> > Thanks in advance for any help.

> > Stu



Mon, 29 Dec 2003 05:45:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem passing ADO command objects as parameters in MTS

2. Problem passing parameters to DataReport/command object

3. problem: passing UDT as parameter of a method for MTS Component

4. problem: passing UDT as parameter of a method for MTS Component

5. passing a collection to a mts object with a ADO recordset

6. ADO, Oracle, MTS, using command object to open Recordset

7. 2nd Request - Passing parameters to ADO Data Environment command

8. Passing parameter to a command object

9. ] Problem passing ADO recordsets to VB6 MTS Component

10. ] Problem passing ADO recordsets to VB6 MTS Component

11. Problem sending ADODB.Command object across MTS packages !!!

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

 

 
Powered by phpBB® Forum Software