Reputation: 117
This is the SQL.
dtaadpResult.SelectCommand.CommandText = " SELECT * FROM tblResult WHERE EventID =" & EventID(Counter1) & " AND ORDER BY Time DESCENDING"
It happens when I attempt to fill the dataset.
dtaadpResult.Fill(dtasetSD, "tblResult")
I'm using MS access, do I add paranthesis? How would I do that.
Upvotes: 0
Views: 57
Reputation: 154995
Your code is potentially vulnerable to SQL injection. Use parameters instead of string concatenation.
With that obligatory warning out of the way, look at your query text after formatting it:
SELECT
*
FROM
tblResult
WHERE
EventID = @eventId
AND
ORDER BY
Time DESCENDING
The problem is you have an AND
statement followed by ORDER BY
, when you should have a predicate clause instead.
Either add another clause, or remove the AND
operator keyword.
Also, more protips:
Results
instead of tblResult
.SELECT
query and passing it to a DataAdapter
just to fill a DataTable
or DataSet
you're wasting memory and CPU cycles, instead use a DataReader
instead: it's much faster (and with a considerably lower memory overhead).Upvotes: 1