this.deliveryTableAdapter.Fill(this.deliveryItemsDataSet1.Delivery);
connectionString =WareHouseConnection.connectionString;
DeliveryItemOleDb =newOleDbConnection(connectionString);
//DateTime
dateF = txtStart.Text;
DateTime
dateF = DateTime.ParseExact(dateTimePicker1.Text,"dd/MM/yyyy",newCultureInfo("en-GB"));
DateTime
dateE = DateTime.ParseExact(dateTimePicker2.Text,"dd/MM/yyyy",newCultureInfo("en-GB"));
label3.Text = dateF.ToShortDateString();
label4.Text = dateE.ToShortDateString();
try
{
DeliveryItemOleDb.Open();
dsWV =newDataSet();
//OleDbCommand
DelCommand = new OleDbCommand("SELECT ID, Barcode, ProductName, CompanyName, Quantity, Price, DeliveredOn, EXPDate, UserName FROM [Delivery] WHERE DeliveredOn BETWEEN @StartDate AND @FinishDate", DeliveryItemOleDb);
DelCommand.CommandText ="SELECT
ID, Barcode, ProductName, CompanyName, Quantity, Price, DeliveredOn, EXPDate, UserName FROM [Delivery] WHERE DeliveredOn BETWEEN @StartDate AND @FinishDate";
DelCommand.Parameters.AddWithValue("@#StartDate#",
dateTimePicker1.Value.Date.ToShortDateString());
DelCommand.Parameters.AddWithValue("@#FinishDate#",
dateTimePicker2.Value.Date.ToShortDateString());
daWV.SelectCommand = DelCommand;
daWV.Fill(dsWV,"Delivery");
dataGridView.DataSource = dsWV.Tables["Delivery"];
//DeliveryItemOleDb.Open();
//dsWV
= new DataSet();
//sqlWV
= "SELECT ID, Barcode, ProductName, CompanyName, Quantity, Price, DeliveredOn, EXPDate, UserName FROM [Delivery] WHERE DeliveredOn (Date as datetime) =#" + label3.Text.ToString() + "#";
//daWV
= new OleDbDataAdapter(sqlWV, DeliveryItemOleDb);
//daWV.Fill(dsWV,"Delivery");
//numRowsWV
= dsWV.Tables["Delivery"].Rows.Count;
}
catch
(Exception
err)
{
MessageBox.Show("Please
Enter Valid Date!!!"+Environment.NewLine+ "A
database error has occurred: "+Environment.NewLine+ err.Message);
//MessageBox.Show("A
database error has occurred: " + Environment.NewLine + err.Message);
}
finally
{
DeliveryItemOleDb.Close();
}
Can anyone help me please, basically im trying to display all the data from one table on a DGV then allow the user to choose between which dates they would like to see the data.