我在其他程序员的帮助下编写了这段代码。此代码在 Windows 7 上运行时运行良好,但当我在 Windows XP 上安装程序时登录失败。我已经在 Windows XP 机器上安装了 Crystal Reports 的 .Net Framework 4.0 和 CRforVS_13_0_3。
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
label2.Text = Convert.ToString(BAssistencia.nroo);
ReportDocument segredo = new ReportDocument();
segredo.Load(@"C:/Relatorios/CrystalReport3.rpt");
ParameterField pf1 = new ParameterField();
ParameterFields pf1s = new ParameterFields();
ParameterDiscreteValue pdv = new ParameterDiscreteValue();
TableLogOnInfo tabla = new TableLogOnInfo();
TableLogOnInfos tablas = new TableLogOnInfos();
ConnectionInfo infocon = new ConnectionInfo();
Tables crtables;
infocon.ServerName = "server";
infocon.DatabaseName = "database";
infocon.UserID = "user";
infocon.Password = "password";
infocon.IntegratedSecurity = false;
crtables = segredo.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table crtable in crtables)
{
tabla = crtable.LogOnInfo;
tabla.ConnectionInfo = infocon;
crtable.ApplyLogOnInfo(tabla);
}
pf1.Name = "@pedido";
pdv.Value = label2.Text;
pf1.CurrentValues.Add(pdv);
pf1s.Add(pf1);
crystalReportViewer1.ParameterFieldInfo = pf1s;
crystalReportViewer1.ReportSource = segredo;
我究竟做错了什么???