Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ADO.NET MS-Access
I had written following query in table adapter for report.
SELECT     RTGSEntries.ReceiptDate, RTGSEntries.ReceiptNo, RTGSEntries.DepositorName, RTGSEntries.DepositorContact, RTGSEntries.AccountNo, 
                      RTGSEntries.AccHolderName, Banks.BankName, Branches.BranchName, RTGSEntries.IFCS, RTGSEntries.Fees, RTGSEntries.Amount, 
                      @Start AS FromDate, @End AS ToDate
FROM         ((RTGSEntries INNER JOIN
                      Banks ON RTGSEntries.BankId = Banks.BankId) INNER JOIN
                      Branches ON RTGSEntries.BranchId = Branches.BranchId)
WHERE     (RTGSEntries.ReceiptDate BETWEEN @Start AND @End)
When I executing query (in query builder) i'm getting this error
 
Error in SELECT clause: expression near '@'.
Error in WHERE clause near '@'.
Unable to parse query text.
 
pls help me.... thx in advance
Posted 30-Sep-12 5:35am
Edited 30-Sep-12 5:44am
RaisKazi32.9K
v2
Comments
Sandeep Mewara at 30-Sep-12 14:22pm
   
Are @Start & @End declared and set before this query execution?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

To declare variables in MS Access 2003 query, you need to do it in this way:
PARAMETERS dStart DateTime, dEnd DateTime;
SELECT ... dStart AS DateFrom, dEnd AS DateTo
...
WHERE ... BETWEEN #dStart# AND #dEnd#
  Permalink  
Comments
Ravi Sargam at 17-Oct-12 12:20pm
   
Thx for reply ML
I written following query
 
PARAMETERS ReceptId NUMBER
SELECT RTGSEntries.RTGSEntryId, RTGSEntries.ReceiptNo, RTGSEntries.ReceiptDate, RTGSEntries.DepositorName, RTGSEntries.DepositorContact,
RTGSEntries.BankId, Banks.BankName, RTGSEntries.AccountNo, RTGSEntries.AccHolderName, RTGSEntries.BranchId, Branches.BranchName,
RTGSEntries.IFCS, RTGSEntries.Amount, RTGSEntries.Fees, RTGSEntries.Note1
FROM ((RTGSEntries INNER JOIN
Banks ON RTGSEntries.BankId = Banks.BankId) INNER JOIN
Branches ON RTGSEntries.BranchId = Branches.BranchId)
WHERE (RTGSEntries.RTGSEntryId = #ReceptId#)
 
but i'm getting this error
 
"Unable to parse query text."
 
pls give reply
Maciej Los at 17-Oct-12 13:34pm
   
Try this:
PARAMETERS ReceptId NUMBER;
SELECT RE.RTGSEntryId, RE.ReceiptNo, RE.ReceiptDate, RE.DepositorName, RE.DepositorContact, RE.BankId, BA.BankName, R.AccountNo, RE.AccHolderName, RE.BranchId, BR.BranchName, RE.IFCS, RE.Amount, RE.Fees, RE.Note1
FROM RTGSEntries AS RE
LEFT JOIN Banks AS BA ON RE.BankId = BA.BankId
LEFT JOIN Branches AS BR ON RE.BranchId = BR.BranchId
WHERE RE.RTGSEntryId = ReceptId

A # is used only with datetime parameters/values. Use ALIASES.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 888
1 OriginalGriff 420
2 CPallini 275
3 George Jonsson 226
4 Richard Deeming 145
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,272
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100