Results 1 to 3 of 3

Thread: Order of Params when calling sproc using ADO Command object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Location
    Reading
    Posts
    70

    Angry Order of Params when calling sproc using ADO Command object

    I'm trying to call a parameterized sproc using the ADO command object. Problem is, that despite the fact that I am referencing the params by name, it still seems to insist that I put them in the order in which they are specified in the sproc.

    Is this true or have I got some sort of setting missing that would allow me to pass the params in a way more suited to my application?

  2. #2
    Member
    Join Date
    Oct 2000
    Location
    Europe
    Posts
    52
    Quite frankly, I don't think it is possible to change the order of your ADO parameters, unless you declare a unique ADODB.Parameter for each parameter.

    Something like:

    dim MyAdoVar1 as ADODB.Parameter
    dim MyAdoVar2 as ADODB.Parameter

    set MyAdoVar1 = new ADODB.Parameter
    set MyAdoVar2 = new ADODB.Parameter


    then for example, MyAdoVar2 is given a value first... =25
    then MyAdoVar1 = 50 (this is not the syntax, just an example)


    But you'll still need to append them in the correct order:

    cmdAdo.Parameters.Append MyAdoVar1
    cmdAdo.Parameters.Append MyAdoVar2


    Hope this helps

    MartinLG
    Tell me, and I will forget. Show me, and I will remember. Involve me, and I will care.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    What version of ADO are you using? ADO 2.6 introduced a new property in the Command object called NamedParameters. If set to True then ADO uses the parameter names (which must
    exactly match the stored procedure parameter names) otherwise it uses the ordinal position.

    This property is provider specific so don't rely on all of them implementing this method. Also I think it is no longer a requirement to create a parameter object for every stored procedure parameter. Parameters that have default values need not be passed.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width