Results 1 to 6 of 6

Thread: [RESOLVED] ADODB Command - Now Populating paramteters automatically!?

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Resolved [RESOLVED] ADODB Command - Now Populating paramteters automatically!?

    Hi there,

    I have some legacy VB6 code that uses ADODB commands to execute stored procedures in an SQL database.

    It's suddenly stopped working. On investigation, it seems that the parameters are being created automatically as soon as I specified the CommandName (i.e. the stored procedure). Our existing code adds the parameters manually so now we've ended up with twice as many parameters and the code execution obviously fails.

    So, I'm wondering if anyone else has experienced this? Is it something in Windows that has changed recently?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: ADODB Command - Now Populating paramteters automatically!?

    I haven't. Could you post the code?
    Please remember next time...elections matter!

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: ADODB Command - Now Populating paramteters automatically!?

    Maybe a change of the Provider?

    Are you using the correct CommandTypeEnum?
    https://learn.microsoft.com/en-us/sq...l-server-ver16

    Any updates on the SQL-Server?

    Is the Parameters-Collection "empty" before calling the SP?
    https://learn.microsoft.com/en-us/sq...l-server-ver16

    In General: Any changes between "working" and not "working"?
    https://learn.microsoft.com/en-us/sq...l-server-ver16
    Last edited by Zvoni; Dec 19th, 2024 at 07:34 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: ADODB Command - Now Populating paramteters automatically!?

    Code:
            Set cmUpdate = New command
            Set cmUpdate.ActiveConnection = cnSource
            cmUpdate.CommandType = adCmdStoredProc
            cmUpdate.CommandTimeout = 120
            cmUpdate.CommandText = strProcName
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("ReturnValue", adInteger, adParamReturnValue)
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("ID", adInteger, adParamInput, , rsSource(strKeyName))
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("LastRead", adBinary, adParamInput, 8, rsSource!LastUpdate_ts)
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("Result", adInteger, adParamOutput)
    As soon as the line in red is executed, the parameters are now fully populated automatically. So the later parameter creation code just duplicates them.

    No code changes and no changes to SQL Server recently (that I am aware of)...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: ADODB Command - Now Populating paramteters automatically!?

    Quote Originally Posted by simonm View Post
    Code:
            Set cmUpdate = New command
            Set cmUpdate.ActiveConnection = cnSource
            cmUpdate.CommandType = adCmdStoredProc
            cmUpdate.CommandTimeout = 120
            cmUpdate.CommandText = strProcName
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("ReturnValue", adInteger, adParamReturnValue)
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("ID", adInteger, adParamInput, , rsSource(strKeyName))
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("LastRead", adBinary, adParamInput, 8, rsSource!LastUpdate_ts)
            cmUpdate.Parameters.Append cmUpdate.CreateParameter("Result", adInteger, adParamOutput)
    As soon as the line in red is executed, the parameters are now fully populated automatically. So the later parameter creation code just duplicates them.

    No code changes and no changes to SQL Server recently (that I am aware of)...
    Sounds like a leftover

    Check the Paremeters-Collection BEFORE executing your red line

    Is it empty? Check the Count-Property

    And try:
    Set cmUpdate = Nothing as the first line (before setting it to a New Command)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  6. #6

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: ADODB Command - Now Populating paramteters automatically!?

    Ah, so my bad. I was on a false trail - simply interrogating the parameters collection forces it to refresh and populate from the database (if it can).

    Thanks for your help and suggestions.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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