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.
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