Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:10:57+00:00 2026-06-15T12:10:57+00:00

I am attempting to create my ADODBcommand and parameters in the calligng code, so

  • 0

I am attempting to create my ADODBcommand and parameters in the calligng code, so that I can pass them into a generic SQL function, but I get an error when retrieving the parameter from the list:

    Dim prm As ADODB.Parameter
    Dim cmd As ADODB.Command
    Dim ParameterList(0) As Variant

    Value = Cells(3,3).Value

    Set cmd = New ADODB.Command
    Set prm = cmd.CreateParameter("@Field", adVarChar, adParamInput, 50)
    cmd.Parameters.Append prm
    cmd.Parameters("@Field").Value = Value    

    ParameterList(0) = prm

    Call SQLFunc(Data, SQLStr, adCmdStoredProc, cmd, ParameterList)
    .
    .

sub SQLFunc(ByRef Data as Variant, SQLStr as String, CommandType As ADODB.CommandTypeEnum, ByRef cmd As ADODB.Command, ParamList As Variant)

    .
    .
    .
    If cmd.CommandType <> adCmdStoredProc Then
        cmd.Execute
    Else

        'Append the parameters
        For i = LBound(ParamList, 1) To UBound(ParamList, 1)
            Dim TempParam As ADODB.Parameter
            Set TempParam = ParamList(i)
            cmd.Parameters.Append TempParam 'Error here
        Next

        Set Rst = cmd.Execute

Could anyone please advise how I can achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:10:58+00:00Added an answer on June 15, 2026 at 12:10 pm

    After

    ParameterList(0) = prm
    

    ParameterList(0) is Empty, to resolve this;

    set ParameterList(0) = prm
    

    I would also strongly type this so instead of variant use Dim ParameterList(0) As ADODB.Parameter

    The error you see occurs because you already append the parameter to the command before calling SQLFunc, in which you illegaly attempt to do so again. Parameter names must be unique when bound to a command.

    You could remove the binding and use;

    Set prm = cmd.CreateParameter("@Field", adVarChar, adParamInput, 50)
    prm.Value = Value
    

    Then prm remains independent of cmd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a function where I can pass names and values that
I am attempting to create some custom map routes but can't get it working
I'm attempting to create a subpage but I'm running into the error mentioned in
I'm attempting to create an xquery expression that will return selected nodes but will
I'm attempting to create a ListView where I can draw some basic shapes into
I attempting to create custom tabs using this . But when I try to
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a cascading dropdown based on the Knockout.js Cart example but
I am attempting to create an unwind segue but nothing will connect to it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.