我遇到了麻烦。
我在我的项目中使用水晶报告。并且在报告文件中工作正常。但在我的WinForm应用程序中始终保持提示登录信息,并输入正确的登录信息。但它给了我错误:"登录失败。请再试一次"
我尝试过:
我的按钮点击活动
int FlightIDParameter = Convert.ToInt32(ReportSelectedFlightNumber.SelectedValue);
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"MYPATH\TestReport.rpt");
cryRpt.SetParameterValue("FLIGHT_ID", FlightIDParameter);
ReportViewer.ReportSource = cryRpt;
ReportViewer.Refresh();
我也试过这段代码
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables ;
cryRpt.Load("my path\TestReport.rpt");
crConnectionInfo.ServerName = "my SERVER NAME";
crConnectionInfo.DatabaseName = "my DB NAME";
crConnectionInfo.UserID = "my USERNAME";
crConnectionInfo.Password = "my PASSWORD";
CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
ReportViewer.ReportSource = cryRpt;
ReportViewer.Refresh();