我有一些来自客户的 Crystal Reports,我需要链接到我们正在创建的 ASP.NET 应用程序。我有以下代码:
LINQDataContext dc = new LINQDataContext();
Order o = dc.Orders.Where(a => a.ID == long.Parse(Request.QueryString["OrderID"])).Single();
SqlConnectionStringBuilder bld = new SqlConnectionStringBuilder(dc.Connection.ConnectionString);
CrystalReportSource src = new CrystalReportSource();
src.ID = "test";
ConnectionInfo myConnectionInfo = new ConnectionInfo();
myConnectionInfo.ServerName = bld.DataSource;
myConnectionInfo.DatabaseName = bld.InitialCatalog;
myConnectionInfo.UserID = bld.UserID;
myConnectionInfo.Password = bld.Password;
src.Report.FileName = o.SalesPersonObject.GetType().GetProperty(Request.QueryString["DeliveryNoteType"]).GetValue(o.SalesPersonObject, null).ToString();
ParameterDiscreteValue param = new ParameterDiscreteValue();
param.Value = long.Parse(Request.QueryString["OrderID"]);
src.ReportDocument.ParameterFields[0].CurrentValues.Add(param);
CrystalReportViewer vw = new CrystalReportViewer();
src.ReportDocument.SetDatabaseLogon(bld.UserID, bld.Password);
vw.HasToggleGroupTreeButton = false;
vw.AutoDataBind = true;
vw.Height = 1268;
vw.Width = 1000;
vw.HasPrintButton = true;
vw.PrintMode = PrintMode.Pdf;
vw.ReportSource = src;
//vw.EnableDatabaseLogonPrompt = false;
vw.HasToggleParameterPanelButton = false;
vw.HasCrystalLogo = false;
vw.RefreshReport();
plcReport.Controls.Add(vw);
但是,即使我使用 SetDatabaseLogon 方法设置用户名/密码,我仍然会收到输入数据库登录详细信息的提示,或者更具体地说是输入密码。我试过使用 vw.EnableDatabaseLogonPrompt = true,但这给了我一个数据库登录问题。
有任何想法吗?