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 9201559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:02:34+00:00 2026-06-17T23:02:34+00:00

How do I pass a SQL Query from C# to Report Server 2008 R2

  • 0

How do I pass a SQL Query from C# to Report Server 2008 R2?

I need to generate a SQL statement from C# dynamically and have it display data in a report using Report Server.

I already declared a parameter and dataset for the report in Report Server. Now I am able to pass the parameter from C# but I also want to pass SQL Query from C# to Report Server.

Thanks in advance.

  • 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-06-17T23:02:35+00:00Added an answer on June 17, 2026 at 11:02 pm

    While this isn’t very secure you could pass the SQL statement to a text field parameter in the report. Then you could pass that statement as a parameter to a stored procedure in SQL Server (assuming you use that). Then you could use sp_executesql to execute the statement.

    http://msdn.microsoft.com/en-us/library/ms188001.aspx

    One issue you may have with this is that the Report Server is going to expect a standard set of columns in your dataset so you will want the statement you pass to have a standard set of columns. I don’t think that reports can handle dynamic fields without a lot of trickery.

    One thing we’ve done to handle “dynamic” columns is have the statement return “field_1”, “field_2”, etc as the result set and then map your report to those generic columns.

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

Sidebar

Related Questions

I am using PHP to query some data on SQL Server 2008 R2 and
Scenario I'm using SQL Server 2005 I have a T-Sql query that has multiple
I have the following Query and i need the query to fetch data from
I have a very weird problem while trying to pass and SQL query using
My app in ASP.NET C#, i use linq to sql to pass data from
This site has a technique to pass xml data around in Microsoft SQL Server:
i have the following sql query select * from tblArea where AreaDescription in ('Processing1','Geology
we have WinForms app which stores data in SQL Server (2000, we are working
I'd like to pass sql query from one page to another page. I'd like
i need to write sql query in string and pass it to linq like

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.