1

I'm getting this error when my code runs and I can't work out why as the syntax looks on point but I could be missing or misunderstanding something

System.Data.SyntaxErrorException: 'Syntax error: Missing operand after 'OrganisationSiteCode' operator.'

This is the code. Treatments is a simple data access layer object. I've tried various syntax changes but still the error.

            Dim siteCode = 'RHA58'
            Dim RowF = $"SiteCode IN (SELECT OrganisationSiteCode FROM vwOrganisations WHERE OrganisationCode = (SELECT DISTINCT OrganisationCode FROM vwOrganisations WHERE OrganisationSiteCode = '{siteCode}'))"
            Treatments.getDataTable.DefaultView.RowFilter = RowF
3
  • 1
    A DataTable is an in-memory container. There are no views or other tables. The filter is used to filter that container's data, not execute SQL. BTW generating SQL using string manipulation is a great way to get hacked. Imagine what would happen if you created a SQL command this way and siteCode contained ); DROP TABLE Users;-- Commented Mar 28 at 16:18
  • @PanagiotisKanavos ah ok thanks - I didn't know that - I haven't used row filters before - I'll find another way Commented Mar 28 at 16:23
  • This question should be deleted. It was based on your misunderstanding of how a DataView works and there isn't really anything that would qualify as a good answer. If you disagree, please provide that good answer and accept it. Don't leave unanswered questions lying around unless you're actually still hoping for an answer. Otherwise, please delete it. Commented Apr 2 at 7:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.