动态数据源和记录选择 [英] Dynamic Datasource and Record Selection
问题描述
我正在尝试构建一个应用程序的一部分有一些困难,但这里有一些背景知识。
我是大学的学生马里兰州,我正在为大学的一个部门写一个
的申请。
对于具有大量额外
功能的访问数据库来说是一种前端。这包括报告。首先,
用户可以更改应用程序使用的数据库,因此我将
存储在appsetting中。出于这个原因,我必须告诉报告在运行时使用什么
数据库而不是使用数据库专家。
我正在构建一种报告向导,其中用户选择某些
值,并根据这些值,报告
从更改中获取数据的SQL语句。因此几乎关于报告的
数据的所有内容都是动态的,并将在运行时确定。
例如,如果用户按章节名称选择官员报告,我这样做(章节是逗号分隔的字符串):
string sel =" SELECT * FROM [Undergrad Leadership] WHERE [Leadership
Position] ='" + txtPosition.Text +"'和[章节名称] IN(" +
章节+");" ;;
部分我迷失了,是如何实际与水晶
报告的接口。在下面的代码中,conn是
正确数据库的OleDbConnection,rep是ReportDocument,view是
CrystalReportsViewer。
rep.DataSourceConnections [0] .SetConnection(conn.DataSource,conn.Database,false);
rep.RecordSelectionFormula = sel;
view.ReportSource = rep ;
当我尝试加载报告时,收到以下错误消息:
公式中的错误<记录选择>:这里有一个数字,货币
金额,布尔值,日期,时间,日期时间或字符串。
另外,假设这个公式得到修复,怎么做我实际上从这个公式和数据源获得字段
到我的报告中,因为我不能在
设计时间做到这一点?在此先感谢您的帮助。
-Jared
首先,如果你希望在运行时将字段添加到报表中,这被视为报表创建,并且您需要使Crystal Reports Server或Business Objects Enterprise能够访问RAS sdk。
其次,RecordSelectionFormula用于过滤数据,而不是在报告中选择你想要的数据。
第三,你没有传递连接到水晶报告,你会传递登录信息。 / p>
Hi, I'm having some difficulty with part of an application I'm trying to build, but here's some background first.
I am a student at the University of Maryland, and I'm writing an
application for one of the departments here at the university. It
is sort of a front-end for an access database with a lot of extra
functionality. This includes reports. First of all, the
user can change the databse that the application uses, so I store that
in an appsetting. For this reason, I have to tell the report what
database to use at runtime rather than using the database expert.
I am building a sort of report wizard in which the user selects certain
values, and based upon those values, the SQL statement that the report
gets data from changes. So almost everything about the report's
data is dynamic and will be determined at runtime.
So for example if the user chooses an officer report by chapter names, I do this (chapters is a comma delimited string):
string sel = "SELECT * FROM [Undergrad Leadership] WHERE [Leadership
Position] = '" + txtPosition.Text + "' AND [Chapter Name] IN (" +
chapters + ");";
The part I am lost on, is how to actually interface with crystal
reports. In the following code, conn is an OleDbConnection to the
correct database, rep is the ReportDocument, and view is a
CrystalReportsViewer.
rep.DataSourceConnections[0].SetConnection(conn.DataSource, conn.Database, false);
rep.RecordSelectionFormula = sel;
view.ReportSource = rep;
When I try to load the report, I get the following error message:
Error in formula <Record Selection>: a number, currency
amount, boolean, date, time, date-time, or string is expected here.
Also, assuming this formula gets fixed, how do I actually get fields
from this formula and datasource onto my report, since I can't do it at
design time? Thanks in advance for the help.
-Jared
First, if you want to be adding fields onto the report at runtime, that is considered report creation, and you need to have Crystal Reports Server, or Business Objects Enterprise, to have access to the RAS sdk.
Second, the RecordSelectionFormula is used to filter data, not select the data you want in the report.
Third, you do not pass a connection to crystal reports, you would pass logon information.
这篇关于动态数据源和记录选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!