Sora
Sora

Reputation: 2551

syntax error in expression when trying to select from a DataTable

I am trying this code but I don't know why this problem is occuring.

 DataRow[] filterRow = Productdt.Select("PRODUCT_ID,PRODUCT_NAME where CATEGORY_ID=" + catID);

Is it because of the where clause?

Upvotes: 1

Views: 923

Answers (1)

Adil
Adil

Reputation: 148110

You can not give column names to select by just the filter criteria in select method.

DataRow[] filterRow = Productdt.Select("CATEGORY_ID=" + catID);

The criteria to use to filter the rows. For examples on how to filter rows, see DataView RowFilter Syntax [C#], MSDN.

You are read more about expression here.

Upvotes: 1

Related Questions