Avatar of Thomasian
ThomasianFlag for Philippines

asked on 

Jet/Access Query with Parameters on VS2010

In SQL Server, I can create a dataset with parameters by using the prefix @

e.g.
SELECT *
FROM
  (Table1 As T LEFT JOIN
  Table2 As C ON T.CodeID=C.CodeID) LEFT JOIN
  Table3 As U ON T.UserID=U.UserID
WHERE
  T.TimeIn >= @Date
  AND T.TimeIn < DateAdd("n",1,@Date)

Open in new window


I can then access the parameters using the parameter name "Date".

Now I need to make this work with Jet/Access DB as backend. It seems that it does not recognize @ as a prefix for a parameter since it give an error "Error in WHERE clause near '@'". I googled a little and found that jet uses "?" to specify a parameter but the problem is replacing both @Date from the query with ? will create 2 parameters.

What is the 'correct' way to create a parameterized query in a dataset for Jet?
SSRS.NET ProgrammingMicrosoft Access

Avatar of undefined
Last Comment
Thomasian
ASKER CERTIFIED SOLUTION
Avatar of dqmq
dqmq
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Thomasian
Thomasian
Flag of Philippines image

ASKER

The 1st line ("Parameters...") is giving an error.

Enclosing the parameter names with []s works, but I have to manually add the parameters on the dataset.

Thanks
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo