Link to home
Start Free TrialLog in
Avatar of Gregory3
Gregory3

asked on

Where Query Syntax Help in C# Code Behind

Hope this is an easy one.  I have a combobox in silverlight that is querying from a database service with a where clause.  The data has commas so it works when using the single quotes, but I can't figure out the query code in C# to get the single quotes to work.  

This works outside of Visual Studio
(MBR_112th = 'LastName, FirstName MiddleInitial.')


queryName.OutFields.AddRange(new string[] { "MBR_112TH", "DIST", "WEBSITE", "PERSONAL_WEBSITE" });
queryName.Where = "MBR_112TH = " + QueryComboBoxName.SelectedIndex.ToString();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dwe761
dwe761
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
P.S.

I forgot an opening parentheses on the function call. Corrected below:
queryName.OutFields.AddRange(new string[] { "MBR_112TH", "DIST", "WEBSITE", "PERSONAL_WEBSITE" });
queryName.Where = string.Format("MBR_112TH = '{0}'",  QueryComboBoxName.SelectedIndex.ToString());

Open in new window

Avatar of Gregory3
Gregory3

ASKER

Thanks guys.  Both worked in different situations.