如何使用水晶报告忽略Windows应用程序中的此错误

时间:2009-11-20 06:23:48

标签: c# windows crystal-reports

public void crys()         {

    con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Documents and Settings/techsoft/My Documents/Database.accdb;Persist Security Info=False");
    con.Open();
    OleDbCommand cmm=new OleDbCommand ("select * from Table3",con);
    DataSet ds=new DataSet ();
    OleDbDataAdapter db=new OleDbDataAdapter ();
    db.SelectCommand =cmm ;
    db.Fill (ds);
    comboBox1 .DataSource =ds.Tables [0];
    comboBox1 .DisplayMember ="logindate";
    comboBox1 .ValueMember ="login";
    comboBox1.SelectedIndex = 0;


    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {


        CrystalReport1 cry = new CrystalReport1();
        //cry.SetDatabaseLogon("techsoft", "softTECH123", @"Microsoft Office Access 2007", "Database");
        crystalReportViewer1.SelectionFormula ="{Table3.login}="  +comboBox1.SelectedIndex;
        crystalReportViewer1.ReportSource = cry;

    }

这是我的代码。我的错误是在选择公式中它抛出异常,如“此处需要字符串” PLZ建议一些解决方案

1 个答案:

答案 0 :(得分:0)

试试这个

crystalReportViewer1.SelectionFormula ="{Table3.login}='" +comboBox1.SelectedIndex + "'";