Click here to Skip to main content
15,904,415 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I am working with crystalreport there are some problems.
First I created one report and selected one table, then 'drag and drop'ed the neccessary fields.
Until myReportDocument.SetDataSource(ds1) gets the data what we mentioned in the stored procedure.
But after loading this line CrystalReportViewer1.ReportSource = myReportDocument; we get all the records from the same table.

Please help.
Thanks in advance.


Here is the code we put it in webform:

ReportDocument myReportDocument;
    BLLreport obj_report = new BLLreport();
    protected void Page_Init(object sender, EventArgs e)
    {


        int reportid;
        reportid = Convert.ToInt32(Request.QueryString["reportid"]);

        switch (reportid)
        {
            case 1:
                {

                    getrpt("crptfreemember.rpt");
                    string cat = Request.QueryString["cat"];
                    obj_report.category = cat;
                    DataSet ds1 = new DataSet();
                    ds1 = obj_report.Fn_Print_freemem_Report();
                    myReportDocument.SetDataSource(ds1);
                    myReportDocument.Refresh();
                    CrystalReportViewer1.ReportSource = myReportDocument;
                    //CrystalReportViewer1.DataBind();
                    break;
                }
            case 2:
                {
                    getrpt("crptpremium.rpt");
                    string cat = Request.QueryString["cat"];
                    obj_report.category = cat;
                    DataSet ds1 = new DataSet();
                    ds1 = obj_report.Fn_Print_premmem_Report();
                    myReportDocument.SetDataSource(ds1);
                    myReportDocument.Refresh();
                    CrystalReportViewer1.ReportSource = myReportDocument;
                    //CrystalReportViewer1.DataBind();
                    break;
                }

        }
    }
    public void getrpt(string path)
    {
        TableLogOnInfos crtablelogoninfors = new TableLogOnInfos();
        TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
        ConnectionInfo crconnectioninfo = new ConnectionInfo();
        Tables crtables;
        CrystalDecisions.CrystalReports.Engine.Table crTable;
        myReportDocument = new ReportDocument();
        myReportDocument.Load(Server.MapPath(path));
        crtables = myReportDocument.Database.Tables;
        for (int i = 0; i < crtables.Count; i++)
        {
            crconnectioninfo.ServerName = "xxxxx";
            crconnectioninfo.DatabaseName = "xxxx";
            crconnectioninfo.UserID = "xx";
            crconnectioninfo.Password = "xxx";
            crTable = crtables[i];
            crtablelogoninfo = crTable.LogOnInfo;
            crtablelogoninfo.ConnectionInfo = crconnectioninfo;
            crTable.ApplyLogOnInfo(crtablelogoninfo);
            //crTable.Location = crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);
        }
    }


UPDATE: Resolved by OP himself.
Posted
Updated 17-Nov-10 23:09pm
v3
Comments
thatraja 17-Nov-10 5:46am    
What error you are getting? include that in your question.

1 solution

hai
we got the answer.we hve cngd this step
myReportDocument.SetDataSource(ds1.Tables[0]);

instd of
myReportDocument.SetDataSource(ds1);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900