.NETGURU
Too Few Parameters Error calling query stored in Access Database
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.odbcnet.

Post a new message to this list...

Kenneth Baltrinic
I am calling a query stored in Access that requires a parameter. But the
parameter that I am passing in as part of the command does not seem to be
being recognized.

I have two queries in an Access database. They are:

SELECT [tblEventParticipants].[EventID], [tblEventParticipants].[MemberID],
[tblEventParticipants].[InterestLevelID]
FROM tblEventParticipants
WHERE ((([tblEventParticipants].[MemberID])=[CurrentMemberID]));

And

SELECT qryEventListData.*, qryCurrentMemberParticipation.MemberID,
IIf([DisplayText] Is Null,"Not Interested",[DisplayText]) AS MemberInterest,
IIf([qryCurrentMemberParticipation]![InterestLevelID] Is
Null,0,[qryCurrentMemberParticipation]![InterestLevelID]) AS
MemberInterestLevel
FROM tblInterestLevels RIGHT JOIN (qryEventListData LEFT JOIN
qryCurrentMemberParticipation ON qryEventListData.EventID =
qryCurrentMemberParticipation.EventID) ON tblInterestLevels.InterestLevelID
= qryCurrentMemberParticipation.InterestLevelID;

The important part of the above is:
1) I am calling the second query using an OdbcCommand.GetReader() call.
2) The second query includes uses the first.
3) The first query contains a parameter (CurrentMemberID)

The problem is that I call the query using the following code and get the
following error:

string sQuery =
"SELECT * FROM qryEventListDataWithParticipation";

OdbcCommand cmdGetEvents = new OdbcCommand(sQuery,
EventDataWrapper.Connection);

OdbcParameter oMemberID =
cmdGetEvents.Parameters.Add("CurrentMemberID", OdbcType.Int, 4);
oMemberID.Value = miCurrentMemberID;

OdbcDataReader dr = cmdGetEvents.ExecuteReader();

ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
Expected 1.

Can anyone explain why the parameter that I am creating is not being
recognized? For what it is worth, I have attempted calling the first query
directly just to test, but that resulted in the same error.

Reply to this message...
 
    
Val Mazur
Hi Kenneth,

When you call stored query, then you should call it as a stored procedure,
not using SELECT statement. Your query should be like this and you also need
to set CommandType of your command to specify that this is a stored
procedure

string sQuery ="qryEventListDataWithParticipation";

--
Val Mazur
Microsoft MVP

"Kenneth Baltrinic" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Data.CommandType
System.Data.Odbc.OdbcCommand
System.Data.Odbc.OdbcDataReader
System.Data.Odbc.OdbcParameter
System.Data.Odbc.OdbcType




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification