Skip to Content
0
Former Member
Aug 04, 2016 at 04:26 PM

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

94 Views

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