I have coded for a date range crystal report but when i run its shows an error
here is error message. Error shows in Form2.designer.cs section.
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Threading.Tasks;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.OleDb;
namespace MyApplication
{
public partial class Form2 : Form
{
OleDbConnection connection = new OleDbConnection();
public Form2()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
ReportDocument cryrep = new ReportDocument();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [tblTransaction] WHERE [TDate] between @FormDate AND @ToDate", connection);
da.SelectCommand.Parameters.AddWithValue("@FromDate", txtFromDate.Text);
da.SelectCommand.Parameters.AddWithValue("@ToDate", txtToDate.Text);
DataSet ds = new DataSet();
da.Fill(ds, "tblTransaction");
cryrep.Load(@"C: \Users\Nandika\Desktop\MyApplication - 1\MyApplication\CrystalReport.rpt");
cryrep.SetDataSource(ds);
crystalReportViewer1.ReportSource = cryrep;
ds.Dispose();
}
}
}
here is error message. Error shows in Form2.designer.cs section.
