VB 2005 and Access Parameter Query Error



Hi,

I wonder if anyone can help me out.

I've written a parameter query in Access 2003, and I'm trying to return the data to a VB 2005 app.
I keep getting the following error message:
"ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1."


First, the Access SQL:

PARAMETERS [@user_ref] Long;
SELECT Users.User_ref, Users.User_ID, Users.User_forename, Users.User_surname
FROM Users
WHERE (((Users.User_ref)=[@user_ref]));

(this works as it should in Access).

Next, the VB 2005 code to Access the Data Layer:

Dim ds As New DataSet
CDAL.AddParameter("[@user_ref]", 3)
ds = CDAL.ExecuteDataSet("EXECUTE usp_user_Get", CommandType.StoredProcedure)

Next the DAL code:

Public Function ExecuteDataSet(ByVal query As String, ByVal commandtype As CommandType, ByVal connectionstate As ConnectionState) As DataSet
Dim adapter As DbDataAdapter = objFactory.CreateDataAdapter
objCommand.CommandText = query
objCommand.CommandType = commandtype
adapter.SelectCommand = objCommand
Dim ds As DataSet = New DataSet
System.Diagnostics.Debug.Print(objCommand.Parameters(0).ToString)
Try
adapter.Fill(ds)
Catch ex As Exception
HandleExceptions(ex)


It gets to the Adapter.Fill method, then throws the above error. I've checked the Command object, and the parameter is stored in there.

I'd be very grateful if anyone can shed some light on this.

Regards

Jules


.



Relevant Pages

  • Re: It wont work after converted from 97 to 2003
    ... query, ... The error message came on. ... I converted it to 2003 but not work on a parameter query. ... When I press "Esc" ...
    (comp.databases.ms-access)
  • Re: OutputTo to Excel question
    ... I can't help you with the macro error message as I don't use macros. ... the result from a query. ... Save a query that pulls the same data as the report. ...
    (microsoft.public.access.macros)
  • Re: Background Web Queries flaws!
    ... There is no way to trap errors on a background query. ... There is no way to control the timeout setting. ... The basic problem is that IE spits an error message before returning control ... > hard coded a 5 minute limit into the web query system. ...
    (microsoft.public.excel.programming)
  • Re: Update Query only works first time
    ... I don't know either -- but that is what you error message says -- perhaps you are not using an updateable recordset or records were locked by something else like a form or query ... Microsoft Access MVP 2006 ... It works the first time, but then there is a very long error message with several reasons why it does not work. ...
    (microsoft.public.access.queries)
  • Re: SQL Compact Edition does not recognize parameter
    ... you might try looking in the debugger to see what the parameters collection looks like before you execute the query. ... assured that all computers have the same installation. ... It's always the same error message althought there are 35 parameters ... Only the hardware is different but on one PDA the problem exists ...
    (microsoft.public.sqlserver.ce)