Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii friends, my line of code is

dv.RowFilter = "Date=" + Convert.ToDateTime(reportdate);

Date is the name of a column in my table and is of type Datetime.
reportdate is a variable of type string.

I am getting this SyntaxErrorException.

Syntax error: Missing operand after '12' operator.

plz help me to solve this error.

Thanks.
Posted

1 solution

It is because of missing 'Apostrophe in Row Filter'
When you filter a DataView by setting its RowFilter property to a string watch out for apostrophes or you’ll get an exception. What you need to do is double each apostrophe, e.g. this works:
dv.RowFilter = "CompanyName = 'Margie''s Travel'"


Correct your RowFilter expression and you will be fine.
 
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