设为首页 加入收藏 网站搜索 繁體中文 中国建站网 — 站长资源分享平台

asp.net 水晶报表-主从表关联问题

来源:网络收集 作者:佚名 时间:2007-04-25 23:13:51

一、使用视图meeting将多表关联整合在一起

二、通过Sql语句筛选数据

三、建立和主从表的关联

四、注意在CrystalReport1表中插入子报表的时候,一定要将主从表的关联字段设置好,否则出乱子

主体代码如下:

/// <summary>
  /// Bind CrystalReport
  /// </summary>
  /// <param name="strS">sql</param>
  private void bdReport(string strS)
  {
   oCR = new CrystalReport1();
   SqlConnection cnn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionSqlServer"]);

   SqlDataAdapter cmd1 = new SqlDataAdapter(strS,cnn);

   //Create and fill the DataSet.

   DataSet2 ds = new DataSet2();
   cmd1.Fill(ds,"meeting");

   // SqlDataAdapter cmd2 = new SqlDataAdapter("select * from realplan where rplanid in (select top 10000 planid from ("+sqlStr+")as  a order by planid)", cnn);
   SqlDataAdapter cmd2 = new SqlDataAdapter(SqlIsOper, cnn);
  
   cmd2.Fill(ds,"realplan");

   //Create the relation between the Authors and Titles tables.
   ds.Relations.Add("mo",
    ds.Tables["meeting"].Columns["planid"],
    ds.Tables["realplan"].Columns["rplanid"]);

   //binding reportViewer
   oCR.SetDataSource(ds);

   this.CrystalReportViewer1.ReportSource = oCR;

   //Close the connection.
   cnn.Close();
  
  }

http://skylaugh.cnblogs.com/archive/2006/05/22/406520.html

Tags:

  • 好的评价 如果您觉得好,就请您
      0%(0)
  • 差的评价 如果您觉得差,就请您
      0%(0)
  • 相关文章
    广告赞助

    文章随便看看 设计素材 建站学院 网页模板 视频教程

    网友评论

    共有 0 位网友发表了评论,得分 0 分,平均 0 分    查看完整评论

    用户名: 查看更多评论

    分 值:100分 85分 70分 55分 40分 25分 10分 1分

    内 容:

             通知管理员 验证码: