我想使用C#将表的列动态添加到Crystal Report [英] I want to add columns of table dynamically to crystal report using c#

查看:76
本文介绍了我想使用C#将表的列动态添加到Crystal Report的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人
如何使用sql查询将表的列分配给Crystal报表.
意味着sql查询的用途有所不同.

例如:有些时候从表格中选择*或
有时从表中选择column1,column2.这样
有什么解决办法让我知道吗?

Dear All
How we can assign column of table to Crystal report using sql query.
Means sql query is varying w.r.t purpose.

Ex: Some times select * from table or
Some times select column1,column2 from table. Like that
Have you any solution let me know.

推荐答案

好吧,我将使用动态sql来构建它(您的问题会询问"sql query",所以我不在从此处的代码),并在您的Crystal报表中存储了proc,该proc将参数作为列EG:

Well I would use dynamic sql to build it up(your question asks ''sql query'' so i am staying away from code here), with a stored proc in your crystal report, that takes the parameters as columns EG:

Create proc myprocname
(
@columns varchar(400),
@table varchar(50)
)
AS
Declare @sql varchar(500)
Set @sql = ''SELECT '' + @columns + '' FROM '' + @table
EXEC @sql



(您将需要修改此想法以适合您的需求)

一些额外的阅读这里: http://msdn.microsoft.com/en-us/library/ms188001.asp [ ^ ]



(you will need to modify this thinking to suit your needs)

some extra reading here: http://msdn.microsoft.com/en-us/library/ms188001.asp[^]


这篇关于我想使用C#将表的列动态添加到Crystal Report的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆