I have a dataset created programatically because I have a complex select statement consisting of a complex set of if else to retrieve value from databse. I need to display the retrieved data in my reportviewer.
So I have the code like:
string query = "Select ...";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);
DataSet dSet = new DataSet();
dAdapter.Fill(dSet);
ReportDocument myReport = new ReportDocument ();
myReport.SetDataSource(dSet);
CrystalReportViewer1.ReportSource = myReport;
Now when I run the page, I get the following error at the line: myReport.SetDataSource(dSet);
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException was unhandled by user code
Message="Invalid report file path."
Source="CrystalDecisions.Shared"
StackTrace:
at CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowException(String message, EngineExceptionErrorID id)
at CrystalDecisions.CrystalReports.Engine.ExceptionThrower.ThrowEngineException(String messageID, EngineExceptionErrorID id)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
at Reports_ReportsBySelection.ButtonSearch_Click(Object sender, EventArgs e) in c:\...\Reports.aspx.cs:line 438
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Can anybody please help me with this.
Thanks.
edit: I have checked with debugger and all my dataset is filled, it is not empty.