Hi I have a DataSet and it has a table called Header. The Header table has a field called Long Agency Code. There is table called Wage that also has a field called Long Agency Code. I want to filter the Wage table based on the Long Agency Code available in Header Table. The following code snippet shows below:
DataTable dt = DataSet.Tables["Header"];
DataRowCollection headerRowCollection = dt.Rows;
foreach (DataRow headerRow in headerRowCollection)
{
FixedOutputter outputter = GetOutputter("Header", streamWriter);
MapElementCollection mapElementCollection = MapUtility.GetMapElementCollection(DataMap, "Header", DataMapFormatters);
outputter.OutputSingleRow(headerRow, mapElementCollection);
string filterExpression = "Long Agency Code == '" + headerRow["Long Agency Code"] + "'";
DataRow[] wageRowCollection = DataSet.Tables["Wage"].Select(filterExpression);
It blows up at the very last line with the message: “Syntax error: Missing operand after ‘Agency’ operator.”
Surround
Long Agency Codein [square brackets], and use a single=rather than==.Here is a decent reference: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx
What source did you use when coming up with
Long Agency Code == '(something)'? (It’s wrong!)