Rose Rouge

Rose Rouge

  • NA
  • 27
  • 8.7k

Search Query with multiple fields Winforms

Jun 30 2016 5:15 AM
I need to write a SQL Query for search with multiple fields .
I wrote this sql query but i can't make it work correctly 
(User select  check-box, choose a date between two dates and select Client Name from ComboBox.)
My query something like this :
  1. private void btnRechercher_Click(object sender, EventArgs e)  
  2.         {  
  3. if (radBtnExport.Checked==true||radBtnImport.Checked==true||radBtnTransit.Checked==true||dateFin.Value>dateDebut.Value||comboBox1.SelectedValue.ToString()=="")  
  4.         {  
  5.            SqlConnection con = new SqlConnection("Data Source=Admin-PC\\SQLEXPRESS;Initial Catalog=timar;Integrated Security=True");  
  6.   
  7.             SqlDataAdapter sda = new SqlDataAdapter("Select * from Devis_C_L,Client where Devis_C_L.ClientId = Client.idClient and NomClient='" + comboBox1.Text + "' or Sense='Transit' or Sense='Export' or Sense='Import' and DateTransport between '" + dateDebut.Value.Date.ToShortDateString() + "' and'" + dateFin.Value.Date.ToShortDateString() + "' ", con);  
  8.             DataTable dt = new DataTable();  
  9.             sda.Fill(dt);  
  10.            dataGridView1.DataSource = dt;  
  11.   
  12.         }  
  13. }  
 Please help me !
Thanks in Advance. 
 

Answers (5)