Hello Guys! i want to know how to select data from ms access database in c# from today date i can select data from database between date but when i select today date and get data it;s show me blank. so please help me.Here is my Code!
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "Today Report")
{
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3],[Date] from [Total] Where [Date] = #" + dateTimePicker1.Value.ToString() + "#", VCON);
da.Fill(dt);
CrystalReport4 MYREPORT = new CrystalReport4();
MYREPORT.SetDataSource(dt);
crystalReportViewer1.ReportSource = MYREPORT;
VCON.Close();
}
else if (textBox1.Text == "Custom Report")
{
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3],[Date] from [Total] Where [Date] between #" + dateTimePicker2.Value.ToString() + "# AND #" + dateTimePicker3.Value.ToString() + "#", VCON);
da.Fill(dt);
CrystalReport4 MYREPORT = new CrystalReport4();
MYREPORT.SetDataSource(dt);
crystalReportViewer1.ReportSource = MYREPORT;
VCON.Close();
}
else
{
MessageBox.Show("Sorry! File was not Found:Please Try Again", "Daily Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
What I have tried:
Hello Guys! i want to know how to select data from ms access database in c# from today date i can select data from database between date but when i select today date and get data it;s show me blank. so please help me.Here is my Code!
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "Today Report")
{
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3],[Date] from [Total] Where [Date] = #" + dateTimePicker1.Value.ToString() + "#", VCON);
da.Fill(dt);
CrystalReport4 MYREPORT = new CrystalReport4();
MYREPORT.SetDataSource(dt);
crystalReportViewer1.ReportSource = MYREPORT;
VCON.Close();
}
else if (textBox1.Text == "Custom Report")
{
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3],[Date] from [Total] Where [Date] between #" + dateTimePicker2.Value.ToString() + "# AND #" + dateTimePicker3.Value.ToString() + "#", VCON);
da.Fill(dt);
CrystalReport4 MYREPORT = new CrystalReport4();
MYREPORT.SetDataSource(dt);
crystalReportViewer1.ReportSource = MYREPORT;
VCON.Close();
}
else
{
MessageBox.Show("Sorry! File was not Found:Please Try Again", "Daily Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}