ERROR: "Object Required" when trying to add parameter to ado command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BlackMustard
    New Member
    • Aug 2007
    • 88

    ERROR: "Object Required" when trying to add parameter to ado command

    hi all,

    i get a run-time error '424': Object Required on the last line below, and i can't figure out why...

    [code=vb] Dim adoConn As New ADODB.Connectio n
    Dim adoCmd As New ADODB.Command
    Dim adoRecSet As New ADODB.Recordset

    ' "SELECT dbDescription,d bExternal FROM EuroPrice WHERE dbFAB = '" & Format(txtFAB.T ext, "@@@ @@@ @@@@") & "'"

    adoConn.Connect ionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source = C:\Documents and Settings\qtomly c\My Documents\Price List.mdb" & ";User ID=Admin;Passwo rd=;"
    adoConn.Open

    adoCmd.CommandT ext = "spGetEuro"
    adoCmd.CommandT ype = adCmdStoredProc

    Dim adoParam As New ADODB.Parameter
    adoParam.Name = "@FAB"
    adoParam.Type = adVarChar
    adoParam.Value = Format(Replace( txtFAB.Text, " ", ""), "@@@ @@@ @@@@")

    adoCmd.Paramete rs.Append (adoParam)[/code]

    i got the idea to the adoCmd.Paramete rs.Append (adoParam) command from asp.net, where i would have used .Parameters.Add (adoParam), and figured append would be the same as add here. is it not?
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Usualy this error will come if the object is not there

    debug which line you are getting this error and check for that object.

    Comment

    • BlackMustard
      New Member
      • Aug 2007
      • 88

      #3
      Originally posted by hariharanmca
      Usualy this error will come if the object is not there

      debug which line you are getting this error and check for that object.
      as i said, i get the error on the last line, which is line 18. since i have used both adoCmd and adoParam before, i find it strange that any of them would not be there... but what is the easiest way to "check for an object"?

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Where you are declaring adoParam

        [CODE=vb]adoCmd.Paramete rs.Append (adoParam)[/CODE]

        I see it's there then check for regi

        Okay try like this.

        [CODE=vb]adoCmd.Paramete rs.Append adoParam[/CODE]

        Comment

        • BlackMustard
          New Member
          • Aug 2007
          • 88

          #5
          Originally posted by hariharanmca
          Where you are declaring adoParam

          [CODE=vb]adoCmd.Paramete rs.Append (adoParam)[/CODE]

          I see it's there then check for some other object.
          i have now checked for both adoCmd and adoParam by inserting [code=vb]MsgBox adoParam.Name
          MsgBox adoCmd.CommandT ext
          Exit Sub[/code]
          on which both dialog boxes showed up. their messages were "@FAB" and "{ call spGetEuro }" respectively. What other objects could be needed for this line to work?

          Comment

          • hariharanmca
            Top Contributor
            • Dec 2006
            • 1977

            #6
            Okay try like this.
            [Code=vb]
            adoCmd.Paramete rs.Append adoParam
            [/code]

            Comment

            • QVeen72
              Recognized Expert Top Contributor
              • Oct 2006
              • 1445

              #7
              Originally posted by BlackMustard
              hi all,

              i get a run-time error '424': Object Required on the last line below, and i can't figure out why...

              [code=vb] Dim adoConn As New ADODB.Connectio n
              Dim adoCmd As New ADODB.Command
              Dim adoRecSet As New ADODB.Recordset

              ' "SELECT dbDescription,d bExternal FROM EuroPrice WHERE dbFAB = '" & Format(txtFAB.T ext, "@@@ @@@ @@@@") & "'"

              adoConn.Connect ionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source = C:\Documents and Settings\qtomly c\My Documents\Price List.mdb" & ";User ID=Admin;Passwo rd=;"
              adoConn.Open

              adoCmd.CommandT ext = "spGetEuro"
              adoCmd.CommandT ype = adCmdStoredProc

              Dim adoParam As New ADODB.Parameter
              adoParam.Name = "@FAB"
              adoParam.Type = adVarChar
              adoParam.Value = Format(Replace( txtFAB.Text, " ", ""), "@@@ @@@ @@@@")

              adoCmd.Paramete rs.Append (adoParam)[/code]

              i got the idea to the adoCmd.Paramete rs.Append (adoParam) command from asp.net, where i would have used .Parameters.Add (adoParam), and figured append would be the same as add here. is it not?
              Hi,

              use "Set" keyword to set Text of Command Object :

              [code=vb]
              Set adoCmd.CommandT ext = "spGetEuro"
              [/code]

              U have to use "CreateParamete r" of command object

              [code=vb]
              Dim adoParam As New ADODB.Parameter
              Set adoParam = adoCmd.CreatePa rameter
              adoParam.Name = "FAB"
              adoParam.Type = adVarChar
              adoParam.Value = Format(Replace( txtFAB.Text, " ", ""), "@@@ @@@ @@@@")

              adoCmd.Paramete rs.Append (adoParam)
              [/code]

              Regards
              Veena

              Comment

              Working...