Skip to Content
author's profile photo Former Member
Former Member

Migrating a legacy .rpt file to use ado.net dataset

Hello again,

I am evaluating migration of old (CR 6) reports to VB.net VS2008 (and then to VS2013). Using the CR tools in VS2008. I am having a problem linking the ADO.Net DataSet Object with the legacy report. I think this is due to a naming mismatch from the table/field references in the original legacy .rpt file and the new DataSet table names, etc. Here is what I have attempted ( some code omitted).

Dim odbcCmd As New OdbcCommand

Dim cryRpt As New ReportDocument

odbcCmd.CommandText = "SELECT el.PostDate, el.Severity, el.Message, el.Application, el.ErrorNumber, el.UserName, el.WorkStation, el.Extra FROM el_dbo.eventlog el WHERE el.PostDate >= { ts '2014-12-01 00:00:00' } AND el.PostDate <= { ts '2014-12-08 15:30:00' } "

Dim myAdapter As New OdbcDataAdapter()

myAdapter.SelectCommand = odbcCmd

Dim myDataSet As New DataSet()

myAdapter.Fill(myDataSet, "el")

cryRpt.Load("mtReport.rpt")

cryRpt.SetDataSource(myDataSet)

SetDBLogonForReport(myConnectionInfo, cryRpt)

CrystalReportViewer1.ReportSource = cryRpt

CrystalReportViewer1.Refresh()

I named the Dataset Table as "el" to match the query results. When I look at the contents of the myDataSet, it looks like:

<NewDataSet>

<el>

<POSTDATE>2014-12-01T10:34:26-05:00</POSTDATE>

The report data fields look like this (from the legacy report file)

However, when I run the report, I get this error:

This leads me to believe that the report db fields cannot be found in the ado.net dataset because they are encased in the top-level element. Is this a correct assessment, and if so, how to rectify? Thanks.

i2.PNG (23.0 kB)
i1.PNG (6.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Dec 09, 2014 at 06:03 PM

    You'll need to do the remapping in the report itself using the Set Location option on the Database submenu of the Crystal Reports menu.

    After you've finished the remapping, save the report and it should now work from within your application. This will also upgrade the report to a newer version of Crystal - there was a MAJOR change in the internal structure of the .rpt file with Crystal 9, so upgrading their format is something you'll want to do anyway.

    -Dell

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.