Using variables in dt.select

Hi. I’m using the following code to select rows to keep:

db_in.Select(“[Name] NOT IN (‘A’, ‘B’)”).CopyToDataTable

I’d like to replace ‘A’ and ‘B’ with a variable var1. I’ve tried

db_in.Select(“[Name] NOT IN (var1)”).CopyToDataTable

But that returns an error; "Cannot find column “var1"”.

Any suggestions?

You quotes

Fine hope this expression would help you resolve this
db_in = db_in.Select(“[Name] <> ‘ “ + variable1.ToString + ” ’ AND [Name] <> ‘ “ + variable2.ToString + ” ’ “).CopyToDatatable()

Cheers @mickeymack

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.