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 PRank #280 · 8.8K reputationPosted May 27, 2018, 12:53 AM EDT
Faisal PathanRank #291 · 8.6K reputationPosted May 26, 2018, 3:51 AM EDT
Bhairab DuttRank #799 · 2.9K reputationPosted May 26, 2018, 7:20 AM EDT
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 BibicRank #993 · 2K reputationPosted May 26, 2018, 3:58 AM EDT