I am using VS 2012 with Crystal Reports. I have written a stored Procedure in MySQL with one parameter , i am using this stored procedure in my Crystal report, everything works fine but when i use export option of crystal report and i export the report to PDFs format, it contains empty report as i have set Parameter value to null in Design Time of crystal report. My code s given below.
protected void btn_search_Click(object sender, EventArgs e)
{
string qry = "Call SP_GeneralReport ('" + tbx_ddoCode.Text.ToUpper() + "')";
DataSet ds = Q.sendQueryToReport(qry);
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("GeneralEmpReport.rpt"));
crystalReport.SetDatabaseLogon("root", "", "localhost", "hr");
crystalReport.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = crystalReport;
}
public DataSet sendQueryToReport(string qry)
{
//- if connection is closed then open the connection
if (myConn.State == System.Data.ConnectionState.Closed)
myConn.Open();
//- Create command and then assign Query
myComm = new MySqlCommand(qry, myConn);
myAdapter = new MySqlDataAdapter(myComm);
DataSet ds = new DataSet();
myAdapter.Fill(ds);
// finally close the connection
myConn.Close();
return ds;
}
In browser i pass parameter value to stored procedure using textbook, it show the accurate result in browser , but the problem comes when i export my report then it show me empty report. As to mention here in Design of Crystal report i set default value of storedprocedure to null.