I have a simplet command string in which the query is pulling data from a database that I cannot update.
I get the following error message:
Incorrect syntax near 'S'. Unclosed quotation mark after the character string ''.
The query is:
cmd.CommandText = "select distinct" + "'" + "foam" + "''" + "from tbl_colorFoam WHERE foam <> '' order by foam asc";
What can I do to avoid this error? This is controlled by a drop-down that is populated with items that have apostrphes.
I also tried using regex,
DropDownList selectProgram = (DropDownList)FindControl("drpquickProgram");
Regex.Replace(selectProgram.SelectedValue, " ' ", "''");
but nothing seems to work.