emma

emma

  • NA
  • 1
  • 2.4k

Using datepickers to filter wpf datagrid

Apr 23 2013 3:50 PM
Please help me, I have been stuck on this all day!!

I am wanting to filter results of wpf datagrid using two datepickers. My query i have so far is as follows

Code:
MySqlConnection cs = new MySqlConnection(connectionSQL);
cs.Open();
 
DataSet ds = new DataSet();
 
MySqlDataAdapter da = new MySqlDataAdapter("Select * from Transactions WHERE date BETWEEN '"+datePicker1.Text +"' AND '"+datePicker2.Text +"' ", cs);
 
MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);
 
da.Fill(ds);
 
this.dataGrid1.ItemsSource = ds.Tables[0].DefaultView;
My code has no errors but the dataset returns as empty even though I have got records which correspond to query. 


Does datepicker require any binding in xaml? DBase date field has type of date. and saves dates with this format 2013-03-11

Answers (1)