当我点击第二页时.. 一个对话框打开并再次询问登录信息
这是我点击第二页 http://i.imgur.com/8y70goi.png时出现的错误
这是我的代码
public void LoadReport()
{
crReportDocument = new ReportDocument();
connectionInfo = new ConnectionInfo();
ParameterField paramField1 = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
//p1
paramField1.Name = "id";
paramDiscreteValue1.Value = Request.QueryString["Id"].ToString();
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields.Add(paramField1);
CrystalReportViewer1.ReportSource = crReportDocument;
crReportDocument.Load(Server.MapPath("~/CrystalReport.rpt"));
connectionInfo.ServerName = ConfigurationManager.AppSettings["ServerName"];
connectionInfo.DatabaseName = ConfigurationManager.AppSettings["DataBaseName"];
connectionInfo.UserID = ConfigurationManager.AppSettings["DataBaseUserID"];
connectionInfo.Password = ConfigurationManager.AppSettings["DataBasePasswordName"];
SetDBLogonForReport(connectionInfo);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportViewer1.Visible = true;
DataSet dsTemp = new DataSet();
DBAccess dbAccess = new DBAccess();
SqlParameter spId = new SqlParameter("@Id", Request.QueryString["Id"].ToString());
SqlParameter[] sqlParams = new SqlParameter[] { spId };
dsTemp = dbAccess.ExecuteDataset("sp_GetInvestigationData", sqlParams);
crReportDocument.SetDataSource(dsTemp.Tables[0]);
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportSource1.ReportDocument.SetParameterValue(0, Request.QueryString["Id"].ToString());
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo)
{
TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
{
tableLogOnInfo.ConnectionInfo = connectionInfo;
}
}
谢谢