Crystal reports 为什么我的代码不能在C#中正确运行CristalReport?
我是C#方面的新手,我开发了一些小代码来运行Crystal report,但它挂起了机器,我使用的是VS 2010、access 2007、Crystal report 10和Crystal report 32.OCX 我的代码是:Crystal reports 为什么我的代码不能在C#中正确运行CristalReport?,crystal-reports,Crystal Reports,我是C#方面的新手,我开发了一些小代码来运行Crystal report,但它挂起了机器,我使用的是VS 2010、access 2007、Crystal report 10和Crystal report 32.OCX 我的代码是: private void Form12_Load(object sender, EventArgs e) { ConnectionInfo crConnectionInfo = new ConnectionInfo(); c
private void Form12_Load(object sender, EventArgs e)
{
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.DatabaseName = Application.ExecutablePath + "\\Pharma.accdb";
crConnectionInfo.UserID = "";
crConnectionInfo.Password = "";
cr1.LogOnInfo.Equals(crConnectionInfo); //("sa", "password", @"MS Access Database", "pharma");
ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "CName";
paramDiscreteValue.Value = "AHmed";
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
this.cr1.RefreshReport();
this.cr1.Show();
}
不确定这是否是唯一的问题,但该行不正确:
cr1.LogOnInfo.Equals(crConnectionInfo);
你在这里比较平等
我宁愿尝试:
cr1.LogOnInfo.ConnectionInfo = crConnectionInfo;
它尝试在LogOnInfo对象上分配/设置ConnectionInfo