Crystal Reports SetDataSource Method

G

Guest

In upgrading a Windows Forms project from 2003 to 2005 in VB.Net, I have
errors in setting the datasource for all of my embedded Crystal Report
objects.

What was working in 1.1 was

If Me.myDataAdapter.Fill(Me.myDataSet.myDataTable) > 0 Then
Dim oRpt As ReportClass = New myReport
oRpt.SetDataSource(Me.myDataSet.myDataTable)
Me.CrystalReportViewer1.ReportSource = oRpt
Return
Else : GoTo NODATA

End If


On conversion, every one of these method calls gives the error:

error BC30521: Overload resolution failed because no accessible
'SetDataSource' is most specific for these arguments:
'Public Overridable Sub SetDataSource(dataTable As
System.Data.DataTable)': Not most specific.

Any help on how to fix this would be appreciated. Thanks.
 
L

Linda Liu [MSFT]

Hi John,

Thank you for posting.

In VS2005, the SetDataSource() method of a CrystalReport has has four
override functions. They are SetDataSource(DataSet),
SetDataSource(DataTable), SetDataSource(IDataReader) and
SetDataSource(IEnumerable). If you pass a strong-typed DataTable to the
SetDataSource() method like the following:
oRpt.SetDataSource(Me.myDataSet.myDataTable), the VS2005 compiler consider
this call ambiguous between the SetDataSource(DataTable) method and the
SetDataSource(IEnumerable) method.

To fix the problem, you should cast the datatable instance to DataTable
type. The following is a sample.

oRpt.SetDataSource((DataTable)Me.myDataSet.myDataTable);

Hope this is helpful to you.
If you have any other concerns or need anything else, please don't hesitate
to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top