LogOnInfo for CrystalReportsViewer

Posted by jmgawlik on 13-Feb-2009 12:08

I have another Crystal question, sorry.

I have a CrystalReportsViewer wrapped in a user control. I exposed a property of type CrystalDecisions.CrystalReports.Engine.ReportDocument which I assign to the ReportSource property of the viewer.

In my form I instantiate a new instance of my user control and a ReportDocument. I use the Load() method to load my rpt then assign my user control's ReportSource property to my ReportDocument. Works great.

In order to automate my ODBC login I created a public method in my user control (addLogOnInfo(input logOn as CrystalDecisions.Shared.TableLogOnInfo)) and inside the method I call CrystalReportViewer1:LogOnInfo:Add(logOn). I create a new instance of TableLogOnInfo in the form and set the ConnectionInfo:UserID and ConnectionInfo:Password properties and send that object along in my method call. I don't have any syntax errors and all of the samples that I have found so far say this is correct but I get the following error:

Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or a user-defined type and valid (not Unknown).

Any ideas? It looks logical to me but maybe I'm missing something obvious here.

All Replies

Posted by Admin on 13-Feb-2009 12:27

I have no experience with the Crystal viewer controls, but some suggestions:

Do you execute this somewhere in the constructor before InitializeComponents() is executed? Then the reference to CrystalReportViewer1 would not be valid.

2nd: What does VALID-OBJECT(CrystalReportViewer1:LogOnInfo) return?

I create a new instance of TableLogOnInfo in the form and set the

ConnectionInfo:UserID and ConnectionInfo:Password

Is ConnectionInfo a VALID-OBJECT?

The first approach needs to be identify the line, that is failing. Either with MESSAGE Statements or the Debugger.

Posted by jmgawlik on 13-Feb-2009 13:47

Do you execute this somewhere in the constructor

before InitializeComponents() is executed? Then the

reference to CrystalReportViewer1 would not be valid.

2nd: What does

VALID-OBJECT(CrystalReportViewer1:LogOnInfo) return?

I create a new instance of TableLogOnInfo in the

form and set the

ConnectionInfo:UserID and ConnectionInfo:Password

Is ConnectionInfo a VALID-OBJECT?

Ok, nothing before InitializeComponents().

#2 was what I needed. I had tested one object and didn't think to check CrystalReportViewer1:LogOnInfo. That was it. I forgot to instantiate it.

InitializeComponents().

CrystalReportViewer1:LogOnInfo = new CrystalDecisions.Shared.TableLogOnInfos().

That last statement instantiates the LogOnInfo collection. It's hard to add a new item to a collection without having the collection available. I feel pretty silly now.

This thread is closed