Using "Between" in .Tables(0).DefaultView.RowFilter

Ninnad Jagtap

Active member
Joined
Apr 12, 2005
Messages
35
Programming Experience
Beginner
I have filled dataset and i have date column in it i want to filter data between the dates specified.I tried using "between" but had problem.can any 1 suggest some thing different
 
Hey Ninnad,

This is what I did for the same situation. I wanted to search for records added to my system between the dates specified.

I have a module called modVariables which holds all of my global variables. In here I have StartDate and EndDate.
I.E.
Friend StartDate As Date
Friend EndDate As Date

For my dataAdapter, I have set the SQL Query up so that;
WHERE (DateRequested >= @StartDate) AND (DateRequested <= @EndDate)

Now in my code before I call the dataAdapter.Fill, I have;

VB.NET:
StartDate = dateTimePicker1.text
EndDate = dateTimePicker2.text
dataAdapter1.SelectCommand.Parameters("@StartDate").Value = StartDate
dataAdapter1.SelectCommand.Parameters("@EndDate").Value = EndDate
dataAdapter1.Fill(dataSet1.table1)

So, the two date picker values are set to the Start Date and End Date. These values are then held as variables and passed onto the Parameter values of the dataAdapter.
The dataAdapter then loads the dataSet with records that are greater than or equal to StartDate, and less than or equal to EndDate.

Hope that helps.
Luke
 
The DataView.RowFilter property accepts SQL-like syntax but it does not support the entire SQL2003 or SQL99 spec. If you read the help topic for that property it will direct you to the topic for the DataColumn.Expression property, which uses the same syntax, and there it outlines everything that is valid.
 
Back
Top