Reputation: 5536
I'm getting an annoying error in visual studio for SQL that executes fine.
SELECT InvoiceLines.LineID,
InvoiceLines.InvoiceID,
InvoiceLines.Text,
InvoiceLines.Rate,
InvoiceLines.Count,
InvoiceLines.Rate * InvoiceLines.Count AS LineTotal,
((InvoiceLines.Rate * InvoiceLines.Count) * (1 + Invoices.VatRate / 100)) * (1 - CAST(Invoices.Discount AS money) * InvoiceLines.ApplyDiscount / 100) AS LineTotalIncVat, InvoiceLines.ApplyDiscount
FROM InvoiceLines
LEFT JOIN Invoices ON Invoices.InvoiceID = InvoiceLines.InvoiceID
What LineTotalIncVat is trying to do is compute the total for the invoice item while adding the vat and subtracting the discount, and yes, probably better to do this in code (would if I could)
The error visual studio gives is:
There was an error parsing the query [token line number =1, token line offset =14, token in error = InvoiceLines]
Even though it will validate and execute without a problem in the query builder...
Upvotes: 1
Views: 236
Reputation: 5536
Solved
Deleted the table from the dataset and added it again with exactly the same SQL.
How strange... although not the first time I've had to do this.
Upvotes: 0
Reputation: 49301
Try bracketing the table and column names, it may be having trouble parsing InvoiceLines.Count
because Count
is a reserved word. Try [InvoiceLines].[Count]
.
Upvotes: 3