Updating Data Provider of Crystal Reports(更新 Crystal Reports 的数据提供者)
问题描述
我在我的 VB.NET 项目中创建了多个 Crystal Reports,从 Microsoft Access 2007 (.accdb) 数据库中获取数据.
现在,我正在使用 Microsoft SQL Server (.mdf)Database 更新我的应用程序.
如何将我的所有 Crystal Reports 的数据源从 Access 文件更新为 MDF 文件?
谢谢.
除非有人有更快/更简单的解决方案,否则这是我在 Visual Studio 2010 中使用 MS Access 获取水晶报告的方法.它涉及的程度略高与选择数据源的常规方法相比,它提供了更多的控制,与数据库无关,并且可以在其他方法有时失败的情况下工作(尤其是在我的经验中使用 MS Access).
我将详细说明让报告从头到尾工作的过程(因为整个过程可能对其他人有用),但会突出显示可能对您有用的部分.
1) 从 SAP 站点安装 Crystal Reports.确保您下载的是 exe 文件,而不是 msi 文件(它不起作用):
希望对你有帮助,很抱歉,如果您有任何问题,请询问
I have created number of Crystal Reports in My VB.NET Project getting data from Microsoft Access 2007 (.accdb) Database.
Now, I am updating My Application with Microsoft SQL Server (.mdf)Database.
How Can I Update the Data Source From Access Files To MDF Files For All of My Crystal Reports?
Thanks.
Unless someone has a quicker / simpler solution, here is the approach I use to get crystal reports working with MS Access in Visual Studio 2010. It is slightly more involved than the normal method of selecting a datasource, but it offers more control, is database agnostic and works where the other methods sometimes fail (especially with MS Access in my experience).
I'll detail the process of getting the reports working from start to finish (because the entire process may be useful for others) but will highlight the bits that may be of use to you.
1) Install Crystal Reports form the SAP site. Make sure you download the exe file, NOT the msi one (it doesn't work):
http://scn.sap.com/docs/DOC-7824
2) Change the Target Framework of your app to .Net Framework 4 (NOT client). The Crystal stuff is not included in the basic profile.
3) Add a reference to the Crystal libraries (Crystal Reports for .NET)
4) Add a form, on that form place a Crystal Report Viewer control (from the Reporting section of the Toolbox):
5) Add a CrystalReportDocument and assign it to the CrystalReportViewer control:
To actually populate the report with data you do the following:
1) Output your report schema by executing code that takes your report datatable (from a gateway) and exports the schema. For example:
<TestMethod()>
Public Sub SchemaTest()
Dim dataSet As DataSet = StaticDataGateway.AccountingIncomeTotals
dataSet.WriteXmlSchema("I:Myschema.xml")
End Sub
If you already have your reports created you will probably not need this. Same if you can write the xml by hand (easy once you have a template to work from)
2) You then load this into your report to get the fields which you can then manipulate to produce your report. To do this you right click on database fields in the Report Field Explorer:
3) From here you select Database Expert and choose ADO.net (xml). The logical choice of Access/Excel DAO actually does not work at all in VS 2010. Select your schema file and load it, then double click on the Table1 to populate the Selected Tables view:
4) Now that you have a schema loaded, you will be able to see fields in the fields dropdown which you can drag n drop onto your report:
5) Finally you load a dataset into your report by executing code in the on load event of your form that you placed the reportviewer control on:
i) Make sure you output a dataset (not datatable) from your gateway (or wherever):
Public Shared Function AccountingIncomeTotals() As DataSet
Dim dataSet As New DataSet
Dim dataTable As DataTable = Database.GetDataTable(GetCommand(DBC.Reporting.SPs.AccountingIncomeTotals))
dataSet.Tables.Add(dataTable)
Return dataSet
End Function
ii) Then assign it to the datasource on the report:
Private Sub AccountingIncomeTotals_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
AccountingIncomeTotalsReport1.SetDataSource(StaticDataGateway.AccountingIncomeTotals)
End Sub
The above section will probably be especially interesting to you because it allows you to directly assign the datasource to the report without having to use the crystal select Data Sources UI panel.
There's one other thing required, you need to add "useLegacyV2RuntimeActivationPolicy" To the app.config file:
http://www.codeproject.com/Questions/390643/Error-When-use-of-crystal-report-sap-crystal-13-an
I hope this helps, sorry it's so involved, if you have any questions please ask
这篇关于更新 Crystal Reports 的数据提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更新 Crystal Reports 的数据提供者
基础教程推荐
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01