cancel
Showing results for 
Search instead for 
Did you mean: 

The report field type is not valid Exception trying to add a FieldObject (RAS)

Former Member
0 Kudos

Hello,

I'm trying to add a database field to a Crystal Report using RAS SDK, but when the field is being added to the ReportObjectController an exception is raised:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in ...

Additional information: The report field type is not valid.

This is the code used to create and add the field:

Dim fldObj As CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject

fldObj = New CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject()

fldObj.DataSourceName = rsFields("TableName") & "_" & rsFields("FieldName")

fldObj.Left = rsFields("FieldLeft")

fldObj.Top = rsFields("FieldSectionTop")

fldObj.Name = rsFields("FieldName")

fldObj.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField

pRpt.ReportClientDocument.ReportDefController.ReportObjectController.Add(fldObj, crSection, -1) 'Exception is raised

I have checked that DataSourceName is in the data source and the data definition of the report.

Can anyone help me with this?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Gonzalo,

What SDK are you using and is it the latest?

If you create a report using CR Designer and add that field does it work and how is it reported?

Does it fail on all string fields or just this one?

Don

Former Member
0 Kudos

Hello Don,

Thanks for your response, I'm using RAS Unmanaged SDK, all the code samples are here:

The report is not create in designer, first it is loaded by a dummy rpt file an then all the database and datafields are loaded from a dataset using XML. Please check this post ()

I have tried using the same code in one of the sample application with a pre-created report and it works.

All the FieldObject fails. TextObject, LineObject, Formula Fields and Special fields can be added correctly.

Any ideas about how to fix this?

Thanks!

0 Kudos

Try creating the report in CR Designer and add your data source and then have a look at the field type causing the problem and see what the Designer shows it as.

Then download the app in KBA 2281780, it has a drop down list box to get the field type, see what it shows.

Don

Answers (0)