Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i am querying a datatable like this

DataRow[] dr = dtRec.Select("Priority ='3' && Recommendations='Replace Motor Bearings'");

I am getting an error like exception = {"Syntax error: Missing operand before '&' operator."}
Posted

&& is good for C like languages but not for SQL. For Select method you have to use SQL syntax and therefor replace && with AND...
C#
DataRow[] dr = dtRec.Select("Priority ='3' AND Recommendations='Replace Motor Bearings'");
 
Share this answer
 
Hello ,
Remove '&&' from the query and replace its value by 'AND'.
Try this
DataRow[] dr = dtRec.Select("Priority ='3' AND Recommendations='Replace Motor Bearings'");

for more details check this DataTable.Select Method

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900