posts - 78, comments - 79, trackbacks - 84

My Links

News

View Anthony Trudeau's profile on LinkedIn

Add to Technorati Favorites

Article Categories

Archives

Post Categories

Other Links

Object Required (424) with Parameter collection

I've been racking my brain with an error for quite awhile now regarding adding a parameter to a collection for an ADO Command object.  The scenario is that I have a SQL query called from Access against a SQL Server database that has one character parameter.

The relevant piece of code is:

Dim param As ADODB.Parameter
Set param = cmd.CreateParameter("@p1", adVarChar, adParamInput, 20, val)
cmd.Parameters.Append param

The ADO documentation for the CreateParameter method states:

This method does not automatically append the Parameter object to the Parameters collection of a Command object. This lets you set additional properties whose values ADO will validate when you append the Parameter object to the collection.

When I ran my test function it failed with Object Required and an error number of 424.  I finally noticed that after I called CreateParameter that there was indeed a parameter in the collection.  So it turns out that the ADO documentation in this case is wrong.

I was able to resolve the problem by directly instantiating the Parameter and then appending it to the collection -- that is I did not use the CreateParameter method.

 

Print | posted on Saturday, October 28, 2006 5:47 PM | Filed Under [ bugs ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 1 and type the answer here:

Powered by: