Answer the question
In order to leave comments, you need to log in
Where and what is wrong?
Hello. wrote selection code by type and with a gap. but faced the same problem.
1) when choosing, for example, Type - Income and dates from 05/01/2020 to 05/10/2020, "Income" is displayed only for the 05th and 10th numbers, but not for the 1st. why is that?
2) when adding a new record (Income / Expense), it is displayed in the search form, but when filtered by type and date, it is not found, although it falls into the required range by date, why is that?
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.Combine(new FileInfo(Application.ExecutablePath).DirectoryName, "База данных.mdb"));
DataTable dt = new DataTable();
myConnection.Open();
string query = "SELECT * FROM Accounting WHERE Дата BETWEEN @date1 and @date2 and Тип = @data";
OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(query, myConnection);
oleDbDataAdapter.SelectCommand.Parameters.AddWithValue("@date1", dateTimePicker1.Value);
oleDbDataAdapter.SelectCommand.Parameters.AddWithValue("@date2", dateTimePicker2.Value);
oleDbDataAdapter.SelectCommand.Parameters.AddWithValue("@data", cbSearch.Text);
oleDbDataAdapter.Fill(dt);
myConnection.Close();
dataGridView1.DataSource = dt;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question