0
votes

i am using visual studio 2010 to write a program which uses crystal report. when i supply my linq query result as data source for my crystal report i receive the error : "The report has no tables"

This is my code written in vb.net

Imports System
Imports System.Linq
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports System.Data.Common
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses

Public Class Form1

Dim rpt As New CrystalReport1
Dim context As New InvoiceSystemEntities

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim c = From cust In context.Customers
            Select cust

    rpt.SetDataSource(c)

    CrystalReportViewer1.ReportSource = rpt

End Sub
End Class

My main reason for my concern is that i want to gain control of the query i send to crystal reports so that i set parameters inside the queries rather than use crystal report to set the parameters. Can anyone please help me out?

1
While Creating the Report select Net Objects Under Project Data as your Datasource to the report.vcs
I see. How then do I convert my database entities as objects? Do I use entity framework which generates model classes? Pls help meWilliams Adu
You don't have to do anything. Go to field explorer -> Database fields -> Project Data-> .NET objects . You should see "InvoiceSystemEntities' listed there. Just select and use it your report. Rest of the code should work without any issuevcs
Ok thanks. I am really gratefulWilliams Adu

1 Answers

0
votes

You cannot mix and match the datasource in crystal reports. You should use the same datasource which you have used while designing the report.

To use entity as datasource Go to field explorer -> Database fields -> Project Data-> .NET objects . You should see "InvoiceSystemEntities' listed there. Just select and use it your report. Rest of the code should work without any issue

you can see it how it is done from this tutorial http://tektutorialshub.com/create-crystal-reports-in-asp-net-mvc/