0

我是 C# 的新手,我开发了小代码来运行我的 Crystal 报表,但它挂起机器,我正在使用 VS 2010 访问 2007 和 Crystal 报表 10 和 Crystl32.OCX。

我的代码是:

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();
    }
4

1 回答 1

0

不确定这是否是唯一的问题,但这条线不正确:

cr1.LogOnInfo.Equals(crConnectionInfo); 

你在这里比较平等......

我宁愿尝试:

cr1.LogOnInfo.ConnectionInfo = crConnectionInfo;

它试图在 LogOnInfo 对象上分配/设置 ConnectionInfo。

于 2012-09-22T17:03:10.337 回答