none
用.NET秀Crystall Report時網頁會要我輸入參數欄位和資料庫密碼 RRS feed

  • 一般討論

  • 我使用VS 2005& Crystall Report 10 & SQL 2005 開發,可是執行該網頁常是時會要我輸入參數欄位和資料庫密碼 , 但我已再程式裡輸入了 可幫我看哪裡用錯??

    private void show_report()
        {
            ReportDocument rpt =new ReportDocument();
            String rptid;
            TableLogOnInfo logoninfo=new TableLogOnInfo();
            rptid=Server.MapPath(".")+"
    \\"+"WeeklySALES.rpt";
            rpt.Load(rptid);
            foreach (CrystalDecisions.CrystalReports.Engine.Table tb in rpt.Database.Tables)
            {
                logoninfo = tb.LogOnInfo;
                logoninfo.ConnectionInfo.ServerName = "eis";
                logoninfo.ConnectionInfo.DatabaseName = "DBNAME";
                logoninfo.ConnectionInfo.UserID = "user";
                logoninfo.ConnectionInfo.Password = "pwd";
                tb.ApplyLogOnInfo(logoninfo);
            }

            ParameterValues pv01 = new ParameterValues();
            ParameterDiscreteValue titles =new ParameterDiscreteValue();
            titles.Value = "WEEKLY SALES RUN RATE -up to WK Q3 TAIWAN ";
            //pv01.Add(titles);
            //rpt.DataDefinition.ParameterFields["title"].ApplyCurrentValues(pv01);
            pv01 = rpt.DataDefinition.ParameterFields["title"].CurrentValues;
            pv01.Add(titles);
            rpt.DataDefinition.ParameterFields["title"].ApplyCurrentValues(pv01);
            CRViewer1.ReportSource = rpt;
           
            //CRViewer1.RefreshReport();

        }

     

    2006年8月2日 上午 10:11

所有回覆

  • 用下列的寫法也不行ㄋ ,不管我放在Page_Load or Pgae_Init 都一樣 ,真的很奇怪 若沒連結資料庫 ,單純傳遞參數就可以請教各位大大看可否幫幫忙

     private void show_report()
        {
            ReportDocument rpt =new ReportDocument();
            String rptid;
            TableLogOnInfo logoninfo=new TableLogOnInfo();
            rptid=Server.MapPath(".")+"\\"+"WeeklySALES02.rpt";
            rpt.Load(rptid);
            foreach (CrystalDecisions.CrystalReports.Engine.Table tb in rpt.Database.Tables)
            {
                logoninfo = tb.LogOnInfo;
                logoninfo.ConnectionInfo.ServerName = "eis";
                logoninfo.ConnectionInfo.DatabaseName = "DBNAME";
                logoninfo.ConnectionInfo.UserID = "userid";
                logoninfo.ConnectionInfo.Password = "pwd";
                tb.ApplyLogOnInfo(logoninfo);
            }
            ParameterFields pfs = new ParameterFields();
            ParameterField pf = new ParameterField();
           
            ParameterDiscreteValue pv =new ParameterDiscreteValue();

            pf.ParameterFieldName = "weeklytitle";
            pv.Value= "WEEKLY SALES RUN RATE -up to WK Q3 TAIWAN ";
            pf.CurrentValues.Add(pv);
            pfs.Add(pf);
            CRViewer1.ParameterFieldInfo = pfs;       
            CRViewer1.ReportSource = rpt;
           
            CRViewer1.RefreshReport();

        }

    2006年8月7日 上午 10:50