Reputation: 169
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?
Upvotes: 0
Views: 846
Reputation: 3725
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/
Upvotes: 0