更新 Crystal Reports 的数据提供者

Updating Data Provider of Crystal Reports(更新 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 的数据提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)