I am trying to run the query below with parameter and keep getting the error message,
select distinct count( distinct x.can)
FROM dbo.tblxenon as x
WHERE x.date >= ? and x.date <= ? AND x.acc like 'NT%'
When I type in the dates the query runs fine.
When I change the first date, i.e. x.date >= , to a ? with a typed in date in the second date, i.e x.date <=, the query runs fine.
However, when I change the second date to a ? I get the error message 'The multipart identifier x.date could not be bound.
What am I doing wrong?
Thanking you in advance, guys.
Edit
This is the code with the dates typed in
select distinct count( distinct x.can)
FROM dbo.tblxenon as x
WHERE x.date >= '01/04/2016' and x.date <= '30/04/2016' AND x.acc like 'NT%'
The query runs just fine like this.
When I replace the dates with ? to pass parameters, I get the error.