VB 2005 and Access Parameter Query Error
- From: Jules Wensley <juleswensley@xxxxxxxxx>
- Date: Wed, 14 Dec 2005 05:53:02 -0800
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
.
- Follow-Ups:
- Re: VB 2005 and Access Parameter Query Error
- From: Daniel Crichton
- Re: VB 2005 and Access Parameter Query Error
- Prev by Date: Re: How to get an ADO control in my Excel 2002?
- Next by Date: Re: How to get an ADO control in my Excel 2002?
- Previous by thread: Re: How to get an ADO control in my Excel 2002?
- Next by thread: Re: VB 2005 and Access Parameter Query Error
- Index(es):
Relevant Pages
|
|