每次我运行我的程序时,它都会提示我输入用户名和密码,但即使我输入了正确的用户名和密码,它也会让我保持在同一页面上。所以,我搜索并在我的表单的PageLoad方法中放置了下面可以看到的代码,但问题仍然存在,无法解决。有替代解决方案吗?顺便说一句,我使用VS2008,我的数据库是Oracle 11g。
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
cryRpt.Load(Server.MapPath("~/ADMIN/AdminReport.rpt"));
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);
}
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
厄尼,提前谢谢
您需要在页面加载时检查回发。您正在重置每个回发的报告,这就是您留在第1页的原因。将此添加到您的页面加载方法:
if(!IsPostback)
{
// Your code here
}