cancel
Showing results for 
Search instead for 
Did you mean: 

The field name is not known - issue with subreport

Former Member
0 Kudos

Hi All,

I'm having a problem with a simple report which I hope someone can shed some light on. Details of my development platform are:

Windows 7 Professional 64-bit client

Oracle 11g Database

Crystal Reports v11 R2 with SP4 (v11.5.10.1263)

Visual Studio .NET 2005 SP2 (v8.0.50727.867)

I have created a very simple report (no sub reports) in the CR Designer based on three tables in a development database. I'm using OLE DB (ADO) as the connection method. The report works as expected in preview mode in the CR designer. I then add the report to a Visual Studio.NET (VB) project and again the report performs as expected when connected to the development database. I have code in the application to change the login information of the underlying report tables and this works as expected - when the application is connected to the production database, the report, again, works fine.

However, when I add a simple sub report, I'm having a problem. The sub report is linked to the main report via a parameter field. In the CR Designer, the reports works fine against both the development and production databases. When the report is incorporated into the VB.NET application, the report works fine when connected against the development database. However, when the application is connected to the production database I get the following error:

"Error in formula <Record Selection>.

'{MEMBERS.CODE} = {?p_members_code}'

The field name is not known.

I've been unable to resolve this issue after considerable investigation. What I have discovered so far:

1. If the report is opened in CR Designer and previewed I'm prompted to enter the connection details for the data source as expected. If I choose the production database the report previews as normal. When I save the report and incorporate it back into the application - the report works fine when connected against the production database but produces the same error when connected against the development database.

2. The development database is a copy of production so tables are similar on both instances. I have confirmed this in Oracle and the "Verify Database" function in the CR Designer confirms same.

3. Hard-coding a value for the parameter {?p_members_code} in the VB.NET code does not resolve the issue

4. Remove the sub report and all is well

Would be grateful for any assistance offered....Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Use Service Pack 6 to be supported on Windows 7.

In code are you setting logon info for the subreport?

And how are you setting logon info and updated DB Server in code from Dev to Prod?

Have you tried any of our samples?

Thank you

Don

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Don,

Thanks for the reply. I will upgrade to SP6 and see how I get on.

The VB.NET application accepts the userid, password and database name from the user. The code below is then used to update the logon info of all the tables in the report, including the sub report.

' Set the database location for the main report.

crTables = a_oReport.Database.Tables

For Each crTable In crTables

With crConnInfo

.ServerName = a_sDatabaseServer

.DatabaseName = ""

.UserID = a_sUserID

.Password = a_sPassword

End With

crTableLogonInfo = crTable.LogOnInfo

crTableLogonInfo.ConnectionInfo = crConnInfo

crTable.ApplyLogOnInfo(crTableLogonInfo)

If Not crTable.TestConnectivity() Then

Throw New Exception("Crystal Report table '" + crTable.Name + _

"' has failed a database connection test.")

End If

Next

' Set the database location for any subreports.

crSections = a_oReport.ReportDefinition.Sections

For Each crSection In crSections

crReportObjects = crSection.ReportObjects

For Each crReportObject In crReportObjects

If crReportObject.Kind = _

CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then

crSubreportObject = _

CType(crReportObject, CrystalDecisions.CrystalReports.Engine.SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDataBase = subRepDoc.Database

crTables = crDataBase.Tables

For Each crTable In crTables

With crConnInfo

.ServerName = a_sDatabaseServer

.DatabaseName = ""

.UserID = a_sUserID

.Password = a_sPassword

End With

crTableLogonInfo = crTable.LogOnInfo

crTableLogonInfo.ConnectionInfo = crConnInfo

crTable.ApplyLogOnInfo(crTableLogonInfo)

If Not crTable.TestConnectivity() Then

Throw New Exception("Crystal Report table '" + crTable.Name + _

"' has failed a database connection test.")

End If

Next

End If

Next

Next

I have not been through the samples in detail. Is there a specific sample you would recommend on how to correctly implement sub reports?

Thanks.

0 Kudos

Hello,

Any one of the samples will have database connection info...

Don't test connectivity after setting the main report, I believe this also tests the subreport connection info.

Try changing your exception message so you know if it fails in the main or subreport.

Thank you

Don