更新Crystal Reports的数据提供程序 [英] Updating Data Provider of Crystal Reports

查看:487
本文介绍了更新Crystal Reports的数据提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的VB.NET项目中创建了多个水晶报表从Microsoft Access 2007(.accdb)数据库获取数据。



现在,



如何将数据源从访问文件更新到所有我的水晶报表的MDF文件?



感谢。

解决方案

除非有人有更快/更简单的解决方案,我使用在Visual Studio 2010中使用MS Access的水晶报告。它比选择一个数据源的正常方法更多的参与,但它提供了更多的控制,是数据库不可知的,其他方法有时会失败(尤其是与MS访问在我的经验)。



我将详细介绍从开始到结束的报告工作过程(因为整个过程可能对其他人有用),但会突出显示使用。



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的数据提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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