Visual Studio TableAdapter syntax error on SQL statement

176 Views Asked by At

This is getting pretty annoying. This SQL statement runs fine in Access:

SELECT payrecords.*, employees.name AS employee
FROM Payrecords 
INNER JOIN employees ON payrecords.employee_id = employees.id
WHERE payrecords.payrun_id = ?
ORDER BY employees.name;

But the tableadapter wizard insists there is a syntax error. Even when when I replace the "?" with an actual id it whines. This happens on a number of non-vanilla SQL statements. Sometimes when I ignore the "error" the code runs fine, but sometimes not. This happens in VS 2010 and 2015. Is there a work-around maybe?

1

There are 1 best solutions below

1
Gord Thompson On BEST ANSWER

The TableAdapter query parser in Visual Studio seems to have difficulty dealing with (moderately) complex SQL statements that end with a semicolon (;). In this case, simply removing the semicolon from the end of the statement resolved the issue.