Hiii
There is a Windows Form with a DataGridView, two TextBoxes and a Button.
date range is given in the TextBoxes as from and to dates.
my problem is when I give date range of the same month, e.g. 05/08/2018 to 20/08/2018, it gives correct records within the date range but, when I give date range within two or more months, e.g. 15/08/2018 to 11/09/2018, it gives all the records regardless the date range given!!! I do not understand what is the problem.
Here is my query...
Select BillSrNo, BillNumber, BillCustName, BillAmtPaid From Billings Where BillDate Between'" + txtFromDt.Text + "' AND '" + txtToDt.Text + "' Order By BillSrNo
Please note that I use MS Access and the DataType is Text. Previously I have tried the same with DateTimePicker and DataType as Date/Time but it gives error. I want to use TextBox, is it possible?
Why it is not giving correct data when date range is between two or more months ?
Thanks
Mayank Jani
Amit GuptaPosted Sep 9, 2018, 1:25 PM
Mayank JaniPosted Sep 10, 2018, 12:42 PM
Mayank JaniPosted Sep 9, 2018, 1:16 AM
Amit GuptaPosted Sep 8, 2018, 4:41 PM
Mayank JaniPosted Sep 8, 2018, 9:02 AM
Amit GuptaPosted Sep 7, 2018, 1:28 PM
Mayank JaniPosted Sep 7, 2018, 1:13 PM
{
DataTable dt = new DataTable();
dt.Load(ReadData);
dgvBillList.DataSource = dt;
dgvBillList.Columns[0].Width = 32;
dgvBillList.Columns[0].HeaderText = "Sr.";
dgvBillList.Columns[1].Width = 90;
dgvBillList.Columns[1].HeaderText = "Bill No.";
dgvBillList.Columns[2].Width = 90; ...
Mayank JaniPosted Sep 7, 2018, 12:20 PM
OleDbDataReader ReadData = FetchBillList.ExecuteReader();
if(ReadData.Read()) //Working good till here.
{
dgvBillList.DataSource = (what should I write here to connect the data with the DGV? or is there anyother way to do so??)
dgvBillList.Columns[0].Width = 32; //Here it throws error.
dgvBillList.Columns[0].HeaderText = "Sr.";
dgvBillList.Columns[1].Width = 90;
dgvBillList.Columns[1].HeaderText = "Bill No.";
dgvBillList.Columns[2].Width = 90; ...
Amit GuptaPosted Sep 7, 2018, 8:53 AM
Mayank JaniPosted Sep 7, 2018, 7:31 AM
dgvBillList.Columns[0].HeaderText = "Sr.";
dgvBillList.Columns[1].Width = 90;
dgvBillList.Columns[1].HeaderText = "Bill No."; //and so on...
Amit GuptaPosted Sep 7, 2018, 2:00 AM
Mayank JaniPosted Sep 7, 2018, 1:44 AM
if (MyConnAcc.State == ConnectionState.Closed)
MyConnAcc.Open();
FetchBillList.Connection = MyConnAcc;
FetchBillList.CommandText=("Select BillSrNo, BillNumber, BillCustName, BillAmtPaid From Billings Where BillDate Between @Fdate AND @TDate Order By BillSrNo");
FetchBillList.Parameters.Add("@FDate", OleDbType.Date);
FetchBillList.Parameters.Add("@TDate", OleDbType.Date);
FetchBillList.Parameters["@FDate"].Value = dtpFrom.Value.ToShortDateString();
FetchBillList.Parameters["@TDate"].Value = dtpTo.Value.ToShortDateString();
FetchBillList.ExecuteNonQuery();
OleDbDataReader ReadData = FetchBillList.ExecuteReader();
if(ReadData.Read())
//Here I need to show the data into a DGV
Amit GuptaPosted Sep 5, 2018, 2:09 PM