DataView RowFilter: using distinct

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following line of code (.NET 2.0):

myDataView.RowFilter = "SELECT DISTINCT CYCLE_DATE";

where CYCLE_DATE is one of my column names. This throws the following
exception:

Syntax error: Missing operand after 'DISTINCT' operator.

Any suggestions on what this is really trying to tell me?

Thanks,
Randy
 
randy1200 said:
I have the following line of code (.NET 2.0):

myDataView.RowFilter = "SELECT DISTINCT CYCLE_DATE";

This is wrong. The RowFilter does not take a "Select" statement. It only
takes the part that would go after the "Where" in a "Select" statement, such
as
myDataView.RowFilter = "field1>27 AND field2<45". Since the "distinct" does
not go after the "where", the dataview is not adequate for doing the kind of
filtering that you want.
 
randy1200 said:
I have the following line of code (.NET 2.0):

myDataView.RowFilter = "SELECT DISTINCT CYCLE_DATE";

where CYCLE_DATE is one of my column names. This throws the following
exception:

Syntax error: Missing operand after 'DISTINCT' operator.

Any suggestions on what this is really trying to tell me?

Thanks,
Randy

IIRC, you can't use DISTINCT in a row filter. There's an article on MSDN
on how to get around this in code, I believe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top