locked
Show crystelRport in Aspx page. RRS feed

  • Question

  • User-1401636618 posted

    I have design a crystelRport in application.

    1. When i open the Report in browser using CrystelReportViewer then It asking for DB credential.

    2. I am trying to set datasource from c# but its not work at all.

    Here is my code:

    if (Request.QueryString["AppID"] != null)
                {
                    string appId = "2";//Request.QueryString["AppID"].ToString(); 
                    ReportDocument objReport = new ReportDocument();
    
                    objReport.Load(Server.MapPath("OnlineAdmissionSuccessReport.rpt"));
    
                    SFISDB DB = new SFISDB();
                    DataSet mainReportDataSource = new DataSet();
                    mainReportDataSource = DB.getDataSet("select * from V_STUDENT_TEMP_DETAILS where APPLICATION_ID='" + appId + "'");
                    objReport.SetDataSource(mainReportDataSource);
    
                    DataSet subReportDataSource = new DataSet();
                    subReportDataSource = DB.getDataSet("SELECT  COLLEGE_CODE [COLLEGE CODE], COLLEGE_NAME [COLLEGE NAME], COURSE_NAME [COURSE NAME], SPECIALIZATION [SUBJECT NAME], OPT_SUBJECTS [OPTIONAL SUBJECTS] FROM F_ONLINE_SELECTED_CO_CU_SP_SE_OPTSUB ('" + appId + "')");
    
                    objReport.Subreports["OnlineAdmissionSuccessSubReport.rpt"].SetDataSource(subReportDataSource);
                    objReport.Database.Dispose();
                    CrystalReportViewer1.ReportSource = objReport;
    
                   // CrystalReportViewer1.RefreshReport();
                    CrystalReportViewer1.DataBind();
                }
    Wednesday, February 8, 2012 2:57 AM

Answers

  • User-1401636618 posted

    I have fixed the first issue by adding below code but not able to fix second one.

    crConnectionInfo.ServerName = "localhost";
            crConnectionInfo.DatabaseName = "";
            crConnectionInfo.UserID = "******;
            crConnectionInfo.Password = "******";
            crConnectionInfo.IntegratedSecurity = true;
    
            CrTables = cryRpt.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 8, 2012 3:14 AM
  • User-1401636618 posted

    Second Issue fixed by below line.

    DataSet mainReportDataSource = new DataSet();
                    mainReportDataSource = DB.getDataSet("select * from V_STUDENT_TEMP_DETAILS where APPLICATION_ID='" + appId + "'");
                   objReport.SetDataSource(mainReportDataSource.Tables[0]);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 8, 2012 5:24 AM

All replies

  • User-1401636618 posted

    I have fixed the first issue by adding below code but not able to fix second one.

    crConnectionInfo.ServerName = "localhost";
            crConnectionInfo.DatabaseName = "";
            crConnectionInfo.UserID = "******;
            crConnectionInfo.Password = "******";
            crConnectionInfo.IntegratedSecurity = true;
    
            CrTables = cryRpt.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 8, 2012 3:14 AM
  • User-1401636618 posted

    Second Issue fixed by below line.

    DataSet mainReportDataSource = new DataSet();
                    mainReportDataSource = DB.getDataSet("select * from V_STUDENT_TEMP_DETAILS where APPLICATION_ID='" + appId + "'");
                   objReport.SetDataSource(mainReportDataSource.Tables[0]);
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 8, 2012 5:24 AM
  • User-1811612959 posted
    Actually there is another simple way for Feeding our own data set. The steps are 1) disable the CR login prompt by setting some dbloginprompt flag to false 2) create your dataset 3) from reportdocument object get the reportclientdocument object 4) from reportclientdocument get the databasecontroller object 5) use databasecontroller objects setDatasource(<Our_dataset>, < Table_name>, <Dataset_table_name>) function to feed your dataset In this way also we are feeding the cr with c# dataset without database login prompt.
    Saturday, February 11, 2012 12:47 PM