2009-11-20 44 views
0

公共無效CRYS(){ 如何使用水晶忽視的Windows應用程序這個錯誤報告

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提出了一些解決方案

回答

0

試試這個

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

謝謝這麼多工作很好 – ush 2009-11-20 06:38:36

+0

歡迎烏斯。將它標記爲答案,如果它工作正常:) – Anuraj 2009-11-20 09:16:44