Wednesday, July 16, 2008

Single quotes Datatable.Select()

Replace single quote for two single quotes, and it will work

string filter = @"DestinationName = '" + destinationName.Replace("'", "''") + "'";
DataRow[] drs = _ds.Tables[0].Select(filter);

foreach (DataRow dr in drs)
{
...
}

No comments: