惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
Y
Y Combinator Blog
月光博客
月光博客
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
小众软件
小众软件
H
Help Net Security
Last Week in AI
Last Week in AI
B
Blog RSS Feed
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog

博客园 - 我本无名

asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票 javascript中setTimeOut 和setInterval的区别 在不同页面之间传递参数 循环不间断显示滚动图片 解决"当前命令发生了严重错误。应放弃任何可能产生的结果。"的问题 - 我本无名 - 博客园 一个不错的,JavaScript代码,显示首页图片幻灯片效果 一个计算数值并进行排序的SQL语句 asp.net上传图片后,在图片上加入自己的背景字 - 我本无名 - 博客园 解决javascript里的中文信息是乱码的问题 javascript特效,信息滚动效果 水晶报表的使用(VS2003+CR9) 关于“响应在此上下文中不可用” 中文VS2008中安装ASP.NET MVC框架,不显示模板 关于split中字符串的问题 OnClientClick的妙用! 一条SQL语句 如何进行软件需求分析 软件需求分析规格说明书格式 (转载)悟透JavaScript
关于水晶报表的多表显示
我本无名 · 2008-04-15 · via 博客园 - 我本无名

有些时候我们做报表,是多个表进行查询。这怎么处理呢。
方法如下:
其它步骤请看前一篇文章
只是在.xsd文件中,多加入一个表,并且将他们相关联

在.aspx文件中代码如下。

            SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=chen123;database=C_News;");
            conn.Open();
            SqlCommand cmd 
= new SqlCommand("",conn);
            
//cmd.CommandText = "select * from C_Article a left join C_BigClass b on a.BigClass=b.BigClass";
            cmd.CommandText = "select * from C_Article";
            SqlDataAdapter da 
= new SqlDataAdapter();
            da.SelectCommand 
= cmd;
            DataSet ds 
= new DataSet();
            da.Fill(ds,
"DataSet1");
            ds.Tables[
0].TableName = "C_Article";

            cmd.CommandText 
= "select * from C_BigClass";
            SqlDataAdapter da2 
= new SqlDataAdapter();
            da.SelectCommand 
= cmd;
            da.Fill(ds,
"DataSet1");
            ds.Tables[
1].TableName = "C_BigClass";
            
//ds.Tables[0].TableName = "DataSet1";

            CrystalReport1 oCR 
= new CrystalReport1();
            oCR.SetDataSource(ds);
            
this.CrystalReportViewer1.ReportSource = oCR;
            
this.CrystalReportViewer1.DataBind();

            conn.Close();

这里有一个很奇怪的问题,如果我使用left join on把二个表联起来查询。它不好用,因为ds.Tables[1].TableName这个值必须是表名,所以没有法子,我写了二个。
不知道有没有什么好的方法。如果有,请你给我留言,十分感谢

此文章只做为自己的代码备份。