Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a column to a DataSet (xsd) for a Crystal Report

I am working on a report and need to add a column to one of my datasets and to the RPT file, but when I try to modify the Data Set, I get an error that the specified table doesn't exist. When I look in the code, it looks like there was originally a table used for this purpose, but this approach has been abandoned, and now this is instead being done with a DataSet in code that is attached to the report.

My problem is that I need to add this new column in the report and I can't seem to get a handle on the data in a way so I can drag my new field onto the report, because I can't find the needed piece of the DataSet because it doesn't exist as it previously did, and the in code DataSet now takes it's place.

Anyone out there able to point me in the right direction for how to go about making this work?

UPDATE: This is roughly how my data set gets to the Crystal Report

private Sub ShowReport()
    Dim dsStatsForPlanned As DataSet = Nothing
    dsStatsForPlanned = DirectCast(Session(CreateSessionKey()), DataSet)
    plannedProductRpt.SetDataSource(dsStatsForPlanned)
End Sub

I have added the additional field that I need in the DataSet that comes in from Session, but am trying to use Designer to get this extra field onto the report, and when I try to refrech or change the Data Source, Designer tells me that the table doesn't exist, presumably because this table exists only in memory, and doesn't tie directly back to a SQL table.

like image 932
Adam Avatar asked Oct 24 '22 06:10

Adam


1 Answers

After several days of digging, and finding a lot of information that was not helpful, I finally managed to find the answer to my issue in a post from 2006 here:

http://sstjean.blogspot.com/2006/12/xsdexe-and-msdatasetgenerator-operate.html

What I did to fix my problem:

  • Manually edit the XSD file in a text editor and add the columns that I needed. This made them appear in my XSD when viewed within Visual Studio.
  • Run the specified Custom Tool for the XSD to regenerate the DataSet. In my case it was the MSDataSetGenerator. This was listed on the Properties tab in VS, and I could right click on the XSD in Solution Explorer and select Run Custom Tool.
  • Open my RPT file and run Verify Databse. This finally indicated that the database had changed and it was updating the report, and I now saw my new field in the Report Designer.
like image 148
Adam Avatar answered Nov 09 '22 03:11

Adam