在运行时将报表查看器绑定到报表源 [英] bind report viewer to a report source during runtime

查看:81
本文介绍了在运行时将报表查看器绑定到报表源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有一个C#程序,该程序使用户可以为一个数据库中无限数量的客户端创建具有特定名称的表.因此,假设我们在一个数据库中有许多名称不同的表.我希望用户可以通过水晶报表打印他想要的每个表的数据,但是我不知道如何将报表源设置为报表查看器,以及如何设计他要打印的页面.
当我们通过使用报告向导"进行操作时,我们可以制作报告并保存,然后可以通过报告查看器进行打印,但是我希望用户每次需要时都可以使用他想要的每张表.
希望我解释得足够好!
请帮助我.

解决方案

表示您的数据库设计很烂,我的意思是真的很糟糕,您遇到了许多要解决的问题中的第一个/c是您糟糕的设计.

让报表期望一个数据集/数据表,并使用动态sql根据特定的名称参数为数据库提供服务.因此,您可以将报表绑定到存储过程(即使您出于设计目的对表名进行了硬编码),并在报表旨在从名称表中获取数据之后更改该过程.


hello everyone
i have a C# program that enables the user to make tables with specific name for the infinite number of clients in one database. so assume that we have lots of tables in one database with different names. i want the user can print the data of each of those tables he wants through the crystal reports but i don`t know how to set the report source to the report viewer and how to design the page he wants to print.
when we go through the "using the report wizard" we just can make a report and save it and then we can print it through report viewer but i want the user make it every time he needs and with every table he wants.
hope i explain good enough !
please help me.

解决方案

Saeed you have one rotten database design, I mean really bad and you are running up against the first of many problems you are going to find b/c of your lousy design.

Have the report expect a dataset/datatable and use dynamic sql to service the data base on a specific name parameter. So you bind your report to a stored procedure (even if you hard code the table name for design purposes) and change the procedure after the report is designed to get the data from the name table.


这篇关于在运行时将报表查看器绑定到报表源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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