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 :
- private void btnRechercher_Click(object sender, EventArgs e)
- {
- if (radBtnExport.Checked==true||radBtnImport.Checked==true||radBtnTransit.Checked==true||dateFin.Value>dateDebut.Value||comboBox1.SelectedValue.ToString()=="")
- {
- SqlConnection con = new SqlConnection("Data Source=Admin-PC\\SQLEXPRESS;Initial Catalog=timar;Integrated Security=True");
-
- 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);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- dataGridView1.DataSource = dt;
-
- }
- }
Please help me !
Thanks in Advance.