tags:

views:

261

answers:

2

Hello,

I've a datatable with a column containing GUIDs. I want to select a row matching a specific GUID. I wrote the following code,

DataRow[] dRows = dtListSettings.Select("ListGUID = " + Convert.ToString(ViewState["GUID"]));

The GUID i'm comparing is 500c2b6a-a3a7-457f-90ed-c96768d91520. But i'm getting the error - Syntax error: Missing operand after 'c2b6a' operator.

Any ideas?

Thank you NLV

+2  A: 

Need a single quote:

Something like:

string.Format("ListGUID = '{0}'", Convert.ToString(ViewState["GUID"]));
ozczecho
You can actually skip the Convert.ToString since String.Format takes Object.
Josh Einstein
+1  A: 

Try surrounding your select statement parameter in single quotes, like this:

DataRow[] dRows = dtListSettings.Select("ListGUID = '" + Convert.ToString(ViewState["GUID"]) + "'");
Jay Riggs
Worked perfect. Thank you.NLV
NLV