首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将参数值传递给Crystal Report中使用的存储过程

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

Stack Overflow用户
提问于 2014-10-24 16:38:22
回答 1查看 1.6K关注 0票数 0

我正在使用VS 2012和Crystal Reports。我用MySQL写了一个带有一个参数的存储过程,我在我的水晶报表中使用这个存储过程,一切正常,但是当我使用水晶报表的导出选项并将报表导出为PDF格式时,它包含空报表,因为我在水晶报表的设计时将参数值设置为null。我的代码如下所示。

代码语言:javascript
复制
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;  
    }

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

EN

回答 1

Stack Overflow用户

发布于 2014-10-25 16:17:23

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

crystalReport.SetParameterValue(0, "parameterValue");

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26544307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档