I am trying to add a string to an SQL statement based on whether an asp:checkbox is checked. Below is what I have, and it isnt working.
I know I could set comm inside the if statement, but I imagine there is a way just to add a variable string to the SQL.
string IndCBSQL;
if (iIndividualsCheckBox.Checked)
{
[COLOR="Red"]IndCBSQL[/COLOR] = "AND CMMaster.CONSTTYPE LIKE 'Individual'";
}
string City = rCity.Text + '%';
[COLOR="blue"]comm[/COLOR] = new SqlCommand(
"SELECT CMMaster.CONTEXIST, CMMaster.IDNUMBER, CMMaster.MAIL_NAME, CMMaster.ADD1, CMMaster.CITY, CMMaster.STATE, CMMaster.ZIP, FROM [CFS].[dbo].[CMMaster] WHERE CMMaster.City LIKE @City" + [COLOR="red"]IndCBSQL[/COLOR], conn);
thanks for the help!