0

i have tried almost everything I could. I have a web app in ASP.net with c#. I am fetching data from the database tables and adding it to dataset. Then I set this dataset as the source to the report. My code is as following.

con.ConnectionString = ConfigurationManager.ConnectionStrings["familyConnectionString"].ConnectionString;

            SqlDataAdapter sda = new SqlDataAdapter("select uid, member_name, gender, dob from family where uid='"+uid+"'", con);
            DataSet1 myds = new DataSet1();
            sda.Fill(myds, "family");


            SqlDataAdapter sda1 = new SqlDataAdapter("select id from birth_certificates where p_id='"+uid+"'", con);
            sda1.Fill(myds, "birth_certificates");

            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath("birth_certi_report.rpt"));
            rpt.Refresh();
            rpt.SetDataSource(myds);
            rpt.SetDatabaseLogon("","",@".\sqlexpress","project2");
            CrystalReportViewer1.ReportSource = rpt;
            CrystalReportViewer1.DataBind();
            CrystalReportViewer1.Visible = true;
            CrystalReportViewer1.RefreshReport();

I am using integrated security so I left username and password blank. Please help.

Asking for Credentials

Please Note that the above code is written inside a DropDown_selectedIndexChanged() event. I tried adding it to the page_load but it didn't work.

4

2 回答 2

1

如果您不担心身份验证,那么就这样做吧。创建一个水晶报表的实例并设置它的数据源。这就是您需要做的所有事情并且它可以工作。*确保水晶报告在您的解决方案中。

        con.ConnectionString = ConfigurationManager.ConnectionStrings["familyConnectionString"].ConnectionString;
      // the magic
        birth_certi_report myreport = new birth_certi_report();
        DataSet1 myds = new DataSet1();
        SqlDataAdapter sda1 = new SqlDataAdapter("select id from birth_certificates where p_id='"+uid+"'", con);
        sda1.Fill(myds, "birth_certificates");
        myreport.SetDataSource(myds);
        crystalReportViewer1.ReportSource = myreport;
于 2013-01-19T10:32:17.537 回答
0

出生证书报告 myreport = 新出生证书报告();

在这一行中,您提到了birth_certi_report 是水晶报告。我的水晶报告名称是 applicationreport 但它显示错误。

将 myreport 变暗为新应用程序报告

错误是类型未定义

于 2015-10-05T03:52:31.983 回答