关注!!!
我也有这样的问题。

解决方案 »

  1.   

    <转>水晶报表参数 
    作者: csdn 类别: C#/VB 日期: 2003-6-9 20:04:18  
     
    CrystalDecisions.Shared.ParameterValues pvCollection=new CrystalDecisions.Shared.ParameterValues();
    CrystalDecisions.Shared.ParameterDiscreteValue pdvCustomerName=new CrystalDecisions.Shared.ParameterDiscreteValue();
    CrystalDecisions.Shared.TableLogOnInfo tliCurrent;
    ReportDocument rptCustomersOrders = new ReportDocument(); 
    try
    {
    rptCustomersOrders.Load("D:\\My Music\\WindowsApplication1\\CrystalReport1.rpt");
    foreach(CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rptCustomersOrders.Database.Tables)
    {
    tliCurrent = tbCurrent.LogOnInfo;
    tliCurrent.ConnectionInfo.ServerName ="localhost";
    tliCurrent.ConnectionInfo.UserID ="sa";
    tliCurrent.ConnectionInfo.Password ="";
    tliCurrent.ConnectionInfo.DatabaseName ="Northwind";
    tbCurrent.ApplyLogOnInfo(tliCurrent); 
    }
    pdvCustomerName.Value = this.comboBox1.Text; 
    pvCollection.Add(pdvCustomerName); 
    rptCustomersOrders.DataDefinition.ParameterFields["@customerid"].ApplyCurrentValues(pvCollection);
    this.crystalReportViewer1.ReportSource= rptCustomersOrders;

    catch( LoadSaveReportException exp)
    {this.label1.Text=exp.Message;}
    //catch (Exception en)
    //{this.label2.Text=en.Message;}