cancel
Showing results for 
Search instead for 
Did you mean: 

Remaining text error when changing the database in use

Former Member
0 Kudos

Hi

This is my first post on this forum. I tried searching for this problem but could not find anything.

I have a VS2005 Winforms application using a number of reports. The approach that I have taken is:

report = new ReportDocument();
report.Load(reportPath);

report.SetDataSource(dataSet.Tables["Data"]);
this.crystalViewer.ReportSource = report;

selectPanel.SetParameterValues(report);

where the datatable is populated with the results of a stored proc execution on SQL Server, and the last line is a virtual function that populates any parameters required by the report. The reports were originally created by referencing the stored proc on a test database, and everything worked great. The reports ran correctly in the design environment and in the application.

Then I moved the application to a production database on the same server. This was done by changing a connection string parameter used by the sproc that populates the dataset. Now all the reports, including several that take no parameters, fail with the error message:

The remaining text does not appear to be part of the formula

..

Error in formula <Record_Selection>

'UNUSED'

The remaining text does not appear to be part of the formula

None of the reports have a formula called <Record_Selection>, so I am assuming that this is an internal function of some sort.

The databases are essentially identical and I have tested the sprocs in the new database. I have also confirmed that the data table is correctly populated before the above code is executed.

Any ideas why this is happening and what I can do to stop this error?

Many thanks

Jonathan

Edited by: Jonathan Dienst on Sep 22, 2008 5:47 PM

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Problem solved!

Somehow, the value UNUSED got into the SelectionFormula and ViewTimeSelectionFormula properties of the CrystalReportViewer control.

I am sure I didn't put them there, so that will have to remain a mystery!

Thanks guys for your time and help.

Jonathan

Former Member
0 Kudos

Thanks Ludek. I tried

report.Database.Tables[0].SetDataSource(dataSet.Tables["Data"]);

(I assume that's what you were suggesting) but unfortunately I am getting the same result.

I also created

(1) a simple new report using the report creation wizard using the XML dataset as the data source...

(2) a simple new report using the stored proc in the production database as the data source...

(3) a blank report (had to skip the SetDataSource statement)

In all cases I got the same error.

When I run the CR sample code for a report from a dataset in VS2005 (CS_Win_Data_Datasets), it runs OK, so the CR runtime is not broken. So now I am very confused...

BTW the refererences in my application are to version CR version 10.2.3600 (same as the sample).

Any more thoughts?

Jonathan

Former Member
0 Kudos

Anyway, its getting late here, so I am stopping for the night. Tomorrow morning I am going to re-create one of the simpler reports from scratch and see if that is a workaround.

If it works, I will consider redoing them all if I cannot find the solution to this problem. But I would prefer not to waste the 2 days that will take if possible

I will post the outcome here.

Thanks again for your help

Jonathan

former_member183750
Active Contributor
0 Kudos

Ok. Rather than recreating the reports, try to use a slightly different code for the dataset . You are using this:

report.SetDataSource(dataSet.Tables["Data"]);

try to use this:

Report.Database.Tables[0].SetDataSource(dataSet.Tables["NAME_OF_Actual_TABLE"]);

Ludek

Former Member
0 Kudos

Ludek

I am actually using the VS report designer, but I was able to follow your suggestion. I created the XML file containing the schema and data from the data table. When I updated the data source, I didn't get a field mapping dialog and the report appeared unchanged (as far as I could see). I confirmed that the data source had changed by checking the properties for the current data source in the set datasource location dialog.

I also ran a verify database to ensure that the report was up to date with the changes.

I ran the report, but I still get the same error ]:-(

Also, (I don't know if this is relevant or not) now the preview in the designer uses CR test data, rather than the data from the database or from the XML.

Regards

Jonathan

Former Member
0 Kudos

Don

Thanks for responding.

The database connection is OLEDB for SQL Server, the report was built using this connection but the run-time data is not supplied by that connection. Rather the application populates the data table that is passed to the report's SetDataSource method. The application uses ADO.Net SQL native drivers.

I am using the report designer in VS2005.

I had assumed that I do not need to update the connection data for the report as the data is supplied in the data table. Does the report care about the connection if the data is supplied by a pre-filled data table?

My problems is that I do not have a report selection field in the reports itself, as the selection is controlled when the application fills the data table. The reports worked properly until I changed the application's connection string to the production database. Now I get this error.

I have confirmed that the data table contains the same data from the production database and the development database, so I am quite confused....

Any more thoughts?

Regards and thanks again

Jonathan

former_member183750
Active Contributor
0 Kudos

When you say that you are using SetDataSource method, I assume you are then passing an ADO .NET dataset to the report(?).

If that is the case, I would recommend writing out the production dataset to an xml, then open the report in the CR designer and point the report at the xml. Eg.;

Use this code to write out the xml, just before you use report.SetDataSource()

myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

Then, copy the above xml top your production computer and:

1) Open the report in the CR designer

2) Go to the Database menu and select "Set DataSource Location..."

3) In the "replace with" pane, expand "Create New Connection"

4) Select ADO .NET (XML)

5) Browse to the XML from the production system

6) Click <Finish>

7) Click on the old datasource in the "Current Data Source" pane

😎 The <Update> button will enable. Click that

What happens at this point? Do you get a field mapping dialog or other? Can you proceed on to actually see the data from the XML?

Ludek

0 Kudos

Hi Jonathan,

What database driver are you using, OLE DB, ODBC, etc.?

Are you using a Developer version of Crystal Reports or the report designer component that comes with .NET? References will be version 10.2.x.x. or ????

The Report itself will have the development connection info saved in the report so you do need to fully qualify all the connection info to the new Production server. If there are any subreports you also need to set table logon info for them also.

The error indicates it's can't find a field, possibly you ahve a Record Selection formula to add filtering. In ther eprot Designer click on the

Thank you

Don