Using Parameters.Refresh From Excel with Jet Returns Count = 0

G

grant.traynor

Hi,

I was hoping someone might know the answer to this one. I'm kind of
new to ADO ... but I've done enough to think that there's something
sinister going on here!

I'm trying to build ADODB.Command object to an Access (Jet) database
from VBA in MS Excel. I'm trying to call a query in the access
database. I'm using Parameters.Refresh to get the parameter list.

When I call Command.Parameters.Refresh, it returns Parameters.Count =
0 and no Parameters objet. I know that the query has parameters!

If I create paramaters manually, then it runs correctly.

If I create the parameters manuall, then call Parameters.Refresh it
deletes all the parameters and still set's Count = 0.

<code snippet>
Set accessCommand = New ADODB.Command
With accessCommand
.ActiveConnection = accessConnection
.CommandType = adCmdStoredProc
.NamedParameters = True
.CommandText = Chr(91) & queryString & Chr(93) ' CHR(43)
is the quote (") character
End With
'' 2(b). Build The Query Parameters into the Command
Dim aParam As ADODB.Parameter
Set aParam = accessCommand.CreateParameter("[Begin Date]",
adDate, adParamInput, , "1-1-1990")
accessCommand.Parameters.Append aParam
Set aParam = accessCommand.CreateParameter("[End Date]",
adDate, adParamInput, , "1-1-2010")
accessCommand.Parameters.Append aParam
accessCommand.Parameters.Refresh
</code snippet>

if I look at accesCommand.Parameters in the VBA debugger before I
execute the last line. My parameters are there! If I go ahead and
create a recordset and save it into excel, it works.

But, if I call accessCommand.Parameters.Refresh .... all my parameters
disappear!

I would be very greatful to anyone who might know how this works, if
I'm doing something wrong, or if there's a Bug in ADO.

I'm using Access 2000 / Excel 2000 and latest ADO and Jet OLEDB
libraries on Windows XP.

Kind Regards,
Grant TRAYNOR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top