Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm looking for the ability to filter data in a range
I made a test file to show the problem : [^]
Any ideas?

What I have tried:

VB
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Dim dv As New DataView(datatable, "DataW>=" & TextBox1.Text & "and DataW<=" & TextBox2.Text, "DataW", DataViewRowState.CurrentRows)
        DataGridView1.DataSource = dv
    End Sub
Posted
Updated 28-Nov-17 17:02pm

1 solution

As per the MSDN documentation - DataColumn.Expression Property (System.Data)[^]
When filtering using Date values you need to surround the value with # or single quotes depending on the data provider.
Additionally, your Text boxes have a string value that you are using to represent a date.
If your datatype in the column DataW is a Date type then I would recommend the format yyyymmdd.

Kind Regards
 
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