生活靠自己
求别人不如求自己!
posts - 6,comments - 2,trackbacks - 0
private void Button1_Click(object sender, System.EventArgs e)
        
{
//            ParameterField ParamField = new ParameterField();
//            ParameterFields ParamFields = new ParameterFields();
//            ParamField.ParameterFieldName = "testname";
//            //离散值 
//            ParameterDiscreteValue DiscreteVal = new ParameterDiscreteValue();
//            DiscreteVal.Value = "panxin";
//            //赋值 
//            ParamField.CurrentValues.Add(DiscreteVal) ;
//            //将该字段加如到字段集合中 
//            ParamFields.Add(ParamField) ;
//            //不允许该字段弹出提示 
//            ParamField.AllowCustomValues = false ;
//             
//            //将公式绑定到具体字段 
//            
//            CrystalReportViewer1.ParameterFieldInfo = ParamFields ;
            
            
            
//this.CrystalReportViewer1.ReportSource="C:\\Inetpub\\wwwroot\\WebApplication1\\bin\\PHReport.rpt";

            ReportDocument rdc
=new ReportDocument();
            rdc.Load(
"C:\\Inetpub\\wwwroot\\WebApplication1\\bin\\PHReport.rpt");
            
//rdc.SetDataSource();
            Subreports subrdcs=rdc.Subreports;
            ReportDocument subrdc
=subrdcs["subreprot1"];
            
//*************************************************
            SqlConnection _connection=new SqlConnection("server=192.168.0.8;uid=sa;pwd=;database=dbtest;persist security info=False;packet size=4096");
            _connection.Open();
            SqlDataAdapter sda
=new SqlDataAdapter("select top 2 * from songs",_connection);
            DataSet ds
=new DataSet();
            sda.Fill(ds,
"songs");
            _connection.Close();            
            
//*********************************************
            subrdc.SetDataSource(ds);            
            subrdc.DataDefinition.FormulaFields[
"formulafield1"].Text="{songs.ssongname}";
            subrdc.DataDefinition.FormulaFields[
"formulafield2"].Text="{songs.ssingername}";

            ParameterField ParamField
= rdc.ParameterFields["testname"];
            ParameterDiscreteValue DiscreteVal 
= new ParameterDiscreteValue();
            DiscreteVal.Value 
= "panxin";
            ParamField.CurrentValues.Add(DiscreteVal);
            
            CrystalReportViewer1.ReportSource
=rdc;
        }
    
posted on 2005-06-30 13:53 MyRiverMan 阅读(284) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。