Problem with BindingSource Filter

syntia.wijaya

Member
Joined
Apr 22, 2007
Messages
24
Location
Indonesia
Programming Experience
Beginner
Hi,

I have a datatable with several columns, which 2 of them is ActualStart and PlanStart. I do some filtering using bindingsource to grab subset of the data in datatable like this:

VB.NET:
bs.Filter = "ActualStart-30 < PlanStart", bs is an instance of BindingSource.

What I'm trying to do is getting row which ActualStart date is 30 days range of PlanStart date. For example: PlanStart #1-Sep-2006#, then all filtered rows have ActualStart > #1-Sep-2006# And ActualStart < #1-Oct-2006#

When doing it, EvaluationException is thrown with error message: Cannot perform '-' operation on System.DateTime and System.Int32. while I tried to use the query in database (SQL Server 2005) with exactly the same code, it works.

So, any suggestion how to solve it?

Thanks in advance.
 
You have to bear in mind that the syntax and expressive capabilities offered by Expression, Filter etc are very very retarded compared to a full on DBMS

Have you thought about getting the db to do the sum?

VB.NET:
SELECT
  a.*
  a.ActualDate - 30 as MonthBeforeActualDate
FROM
  MyTable


...

bs.Filter([MonthBeforeActualDate] > [PlanDate]")
 
Back
Top