By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

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

P: 88
hi all,

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

Expand|Select|Wrap|Line Numbers
  1.     Dim adoConn As New ADODB.Connection
  2.     Dim adoCmd As New ADODB.Command
  3.     Dim adoRecSet As New ADODB.Recordset
  4.  
  5. '    "SELECT dbDescription,dbExternal FROM EuroPrice WHERE dbFAB = '" & Format(txtFAB.Text, "@@@ @@@ @@@@") & "'"
  6.  
  7.     adoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\qtomlyc\My Documents\PriceList.mdb" & ";User ID=Admin;Password=;"
  8.     adoConn.Open
  9.  
  10.     adoCmd.CommandText = "spGetEuro"
  11.     adoCmd.CommandType = adCmdStoredProc
  12.  
  13.     Dim adoParam As New ADODB.Parameter
  14.     adoParam.Name = "@FAB"
  15.     adoParam.Type = adVarChar
  16.     adoParam.Value = Format(Replace(txtFAB.Text, " ", ""), "@@@ @@@ @@@@")
  17.  
  18.     adoCmd.Parameters.Append (adoParam)
i got the idea to the adoCmd.Parameters.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?
Sep 24 '07 #1
Share this Question
Share on Google+
6 Replies


hariharanmca
100+
P: 1,977
Usualy this error will come if the object is not there

debug which line you are getting this error and check for that object.
Sep 24 '07 #2

P: 88
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"?
Sep 24 '07 #3

hariharanmca
100+
P: 1,977
Where you are declaring adoParam

Expand|Select|Wrap|Line Numbers
  1. adoCmd.Parameters.Append (adoParam)
I see it's there then check for regi

Okay try like this.

Expand|Select|Wrap|Line Numbers
  1. adoCmd.Parameters.Append adoParam
Sep 24 '07 #4

P: 88
Where you are declaring adoParam

Expand|Select|Wrap|Line Numbers
  1. adoCmd.Parameters.Append (adoParam)
I see it's there then check for some other object.
i have now checked for both adoCmd and adoParam by inserting
Expand|Select|Wrap|Line Numbers
  1. MsgBox adoParam.Name
  2. MsgBox adoCmd.CommandText
  3. Exit Sub
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?
Sep 24 '07 #5

hariharanmca
100+
P: 1,977
Okay try like this.
Expand|Select|Wrap|Line Numbers
  1. adoCmd.Parameters.Append adoParam
  2.  
Sep 24 '07 #6

QVeen72
Expert 100+
P: 1,445
hi all,

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

Expand|Select|Wrap|Line Numbers
  1.     Dim adoConn As New ADODB.Connection
  2.     Dim adoCmd As New ADODB.Command
  3.     Dim adoRecSet As New ADODB.Recordset
  4.  
  5. '    "SELECT dbDescription,dbExternal FROM EuroPrice WHERE dbFAB = '" & Format(txtFAB.Text, "@@@ @@@ @@@@") & "'"
  6.  
  7.     adoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\qtomlyc\My Documents\PriceList.mdb" & ";User ID=Admin;Password=;"
  8.     adoConn.Open
  9.  
  10.     adoCmd.CommandText = "spGetEuro"
  11.     adoCmd.CommandType = adCmdStoredProc
  12.  
  13.     Dim adoParam As New ADODB.Parameter
  14.     adoParam.Name = "@FAB"
  15.     adoParam.Type = adVarChar
  16.     adoParam.Value = Format(Replace(txtFAB.Text, " ", ""), "@@@ @@@ @@@@")
  17.  
  18.     adoCmd.Parameters.Append (adoParam)
i got the idea to the adoCmd.Parameters.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 :

Expand|Select|Wrap|Line Numbers
  1. Set adoCmd.CommandText = "spGetEuro"
  2.  
U have to use "CreateParameter" of command object

Expand|Select|Wrap|Line Numbers
  1. Dim adoParam As New ADODB.Parameter
  2. Set adoParam = adoCmd.CreateParameter
  3.  adoParam.Name = "FAB"
  4.  adoParam.Type = adVarChar
  5.  adoParam.Value = Format(Replace(txtFAB.Text, " ", ""), "@@@ @@@ @@@@")
  6.  
  7.   adoCmd.Parameters.Append (adoParam)
  8.  
Regards
Veena
Sep 24 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.