Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am using access database , vb.net
to filter my datagridview I used
Sales_ItemsDataGridView.DataSource = Me.M_B_DATABASEDataSet.Sales_Items.Select(("Convert(category, 'System.String') LIKE '" & search2 & "'")


now my problem
my date is string in the Database
date format is 31/12/2001
and i want to filter the dategridview between 2 dates so i uesed
Sales_ListDataGridView.DataSource = Me.M_B_DATABASEDataSet.Sales_List.Select(("Convert(invoice_date, 'System.String')  <= '" & DateTimePicker2.Value & "' AND Convert(invoice_date, 'System.String')   >= '" & DateTimePicker1.Value & "'"))

but sure that gave me funny results as it considered the date as string...
but i failed to change the
("Convert(invoice_date, 'System.String')
to date format
can any one help Please.....
Posted

1 solution

Try with LINQ
C#
Sales_ListDataGridView.DataSource = Me.M_B_DATABASEDataSet.Sales_List.AsEnumerable()
                            .Where(r => r.Field<datetime>("invoice_date") <= DateTimePicker2.Value && r.Field<datetime>("invoice_date") >=DateTimePicker1.Value)
                            .CopyToDataTable();


http://msdn.microsoft.com/en-us/library/bb669073(v=vs.110).aspx[^]
 
Share this answer
 
v2
Comments
Member 10862570 15-Jun-14 9:35am    
Thanks DamithSL, but it didnt work

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