Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:32:51+00:00 2026-05-22T17:32:51+00:00

How can I use a linq query as local report(Microsoft Report) data source (WinForms)?

  • 0

How can I use a linq query as local report(Microsoft Report) data source (WinForms)?
I have a Microsoft Report Viewer Control in MyForm,And I have a linq query as this :

var query = from colV in dal.v_TarafeGharardad join colT in dal.TBL_TarafeGharardad on colV.Id equals colT.PK_Id  select colV;

I want to use the linq query as Microsoft Report Data Source.
I have try this,but I really know it is wrong.

frmReportViewer ReportViewerForm = new frmReportViewer();
            ReportViewerForm.rptViewer.LocalReport.DataSources.Add(new ReportDataSource("v_TarafeGharardad",query));
            ReportViewerForm.rptViewer.LocalReport.ReportPath = Application.StartupPath + "rptTarafeGharardad.rdlc";
            ReportViewerForm.Show();

What is the solution?(Thanks :-*)

Update: If I can convert the linq query to DataTable,the problem has been solved.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:32:51+00:00Added an answer on May 22, 2026 at 5:32 pm

    What you’re doing looks pretty much correct. I do exactly that (this is VB):

    rptViewer.LocalReport.ReportPath = <filepath>
    rptViewer.LocalReport.DataSources.Clear()
    rptViewer.LocalReport.DataSources.Add(New ReportDataSource("<data_source_name_in_report>", <linq_query_result>))
    rptViewer.SetDisplayMode(DisplayMode.PrintLayout)
    

    The one bit you need to check is that you are matching the datasource name that is in the report correctly. You can check this by opening the report in a text editor and looking in the datasources element.

    The other thing from memory, and I’ve not used this in about a year so I might be wrong, I’ve got a niggling feeling you have to call either rptViewer.Refresh() or rptViewer.SetDisplayMode() to force it to render.

    Take a look at this website for plenty of info on the ReportViewer control:

    http://www.gotreportviewer.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create Linq Expression that I can use to query child
Using EF we can use LINQ to read data which is rather simple (especially
Can we use Business Objects which we made & data acess Layer of LINQ?
How to write FirstOrDefault Linq Query in F#? Can I use linq to sql
I have a LINQ query such as: using(csv.......) { csv.Select(x => new Data() {
i have a linq query to get data from a database. something like: Repository.Query<Project>.Where(r=>r.IsActive).OrderBy(r=>r.Date);
I have a LINQ query that looks like this: public IEnumerable<Foo> SelectFooBars() { return
So, I have a simple linq query. Other programmers (all on Win7, VS2010) can
I use this LINQ query in an app I am writing: internal int GetNoteCount(DateTime
Given the following table structure, how can I use a Linq query to return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.