Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将参数值传递给Crystal Report中使用的存储过程_C#_Mysql_Crystal Reports - Fatal编程技术网

C# 将参数值传递给Crystal Report中使用的存储过程

C# 将参数值传递给Crystal Report中使用的存储过程,c#,mysql,crystal-reports,C#,Mysql,Crystal Reports,我将VS2012与Crystal Reports一起使用。 我在MySQL中用一个参数编写了一个存储过程,我在Crystal report中使用这个存储过程,一切正常,但当我使用Crystal report的导出选项并将报告导出为PDF格式时,它包含空报告,因为我在Crystal report的设计时已将参数值设置为null。我的代码如下 protected void btn_search_Click(object sender, EventArgs e) { stri

我将VS2012与Crystal Reports一起使用。 我在MySQL中用一个参数编写了一个存储过程,我在Crystal report中使用这个存储过程,一切正常,但当我使用Crystal report的导出选项并将报告导出为PDF格式时,它包含空报告,因为我在Crystal report的设计时已将参数值设置为null。我的代码如下

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;  
    }

在浏览器中,我使用教科书将参数值传递给存储过程,它在浏览器中显示准确的结果,但问题是当我导出报表时,它会显示空报表。正如在Crystal report的设计中提到的,我将storedprocedure的默认值设置为null。

首先将CrystalReportviewer的EnableParmeterCompt属性设置为true,然后通过Crystalreport对象将参数传递给存储过程对象,如下所示-

crystalReport.SetParameterValue(0,“parameterValue”)