C# Crystal报表数据库登录参数
您好,我有一个使用Crystal report作为报告工具开发的windows base c#应用程序。我已经提供了所有的登录和数据库信息,但当我运行并部署它时。。它仍然要求数据库登录 下面是我的代码C# Crystal报表数据库登录参数,c#,database-connection,crystal-reports-xi,C#,Database Connection,Crystal Reports Xi,您好,我有一个使用Crystal report作为报告工具开发的windows base c#应用程序。我已经提供了所有的登录和数据库信息,但当我运行并部署它时。。它仍然要求数据库登录 下面是我的代码 ReportDocument rpt = new ReportDocument(); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogonin
ReportDocument rpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
rpt.Load("C:/Operation/Reports/po.rpt");
crConnectionInfo.ServerName = "192.4.4.4";
crConnectionInfo.DatabaseName = "Operations";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "xxxxxx";
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = DbClass.PONumber;
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["ParameterPO"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
CrTables = rpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
crpt.Refresh();
crpt.ReportSource = rpt;
问题出在哪里我的头就痛。。。如果有人知道这件事,请告诉我一个想法
谢谢大家! 首先打开您的连接。使用此选项:
SqlConnection myConnection = new SqlConnection("xxx");
myConnection.Open();
// Your Code
myConnection.Close();
然后关闭连接。我想这是没有必要的,因为我在这里没有使用SQL…没有涉及SQL连接,因为我已经在crystal report中设置了字段…我只需要登录信息就可以查看报告。