2013-07-15 150 views
0

我有下面的代碼來傳遞參數打開crsytal報告。但是當它打開水晶報告時,我再次詢問參數以顯示報告。晶體報告問題

 ReportDocument cryRpt = new ReportDocument(); 
     TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); 
     TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); 
     ConnectionInfo crConnectionInfo = new ConnectionInfo(); 
     Tables CrTables; 
     cryRpt.Load(Server.MapPath("DMTR1.rpt")); 
     crConnectionInfo.ServerName = m_strConnectionString.Split(';')[0].Split('=')[1]; 
     crConnectionInfo.DatabaseName = m_strConnectionString.Split(';')[1].Split('=')[1]; 
     crConnectionInfo.UserID = m_strConnectionString.Split(';')[2].Split('=')[1]; 
     crConnectionInfo.Password = m_strConnectionString.Split(';')[3].Split('=')[1]; 
     CrTables = cryRpt.Database.Tables; 
     foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) 
     { 
      crtableLogoninfo = CrTable.LogOnInfo; 
      crtableLogoninfo.ConnectionInfo = crConnectionInfo; 
      CrTable.ApplyLogOnInfo(crtableLogoninfo); 
     } 
     cryRpt.SetParameterValue("@ReceivedDate", Convert.ToDateTime("06/21/2013")); 
     cryRpt.SetParameterValue("@TransferDate", Convert.ToDateTime("08/21/2013")); 
     crysview.ReportSource = cryRpt; 
     crysview.RefreshReport(); 
+0

您是否檢查_crysview.DataBind(); _而不是_crysview.RefreshReport(); _? – Coder

+0

非常感謝。 crysview.DataBind();工作正常,而不是crysview.RefreshReport(); –

+0

那麼現在它不要求參數? – Coder

回答

2

您需要用crysview.DataBind();替換crysview.RefreshReport();