Filter datatable from text box and datetime picker
- private void izvjestajoprodanimartiklima()
- {
- using (SqlConnection openCon = new SqlConnection(cs))
- {
- String saveStaff = "SELECT roba as 'Naziv artikla', SUM (cast(kolicina as float)) as 'Kolicina' from (select roba, kolicina from mp_racun_roba union all select roba, kolicina from mp_faktura_roba) as alltables group by roba";
- if (!string.IsNullOrEmpty(textBox1.Text))
- {
- saveStaff += "roba LIKE '%" + textBox1.Text + "%' ";
- }
- if (checkBox1.Checked)
- {
- String strFilterDTP1 = dateTimePicker1.Value.ToString("yyyy-MM-dd");
- String strFilterDTP2 = dateTimePicker2.Value.ToString("yyyy-MM-dd");
- saveStaff += strFilterDTP1 + " 00:00:00' AND '" + strFilterDTP2 + " 23:59:59' ";
- }
Some help?
Rafnas T PPosted May 27, 2018, 4:53 AM
Bhairab DuttPosted May 26, 2018, 11:20 AM
I think the updated sql query is correct and you can use its with string . Now after that you can add where condition for get the value with like and then use and for date filteration .
Hope Its help you.
Thanks.
Goran BibicPosted May 26, 2018, 7:58 AM
Faisal PathanPosted May 26, 2018, 7:51 AM