ASP.NET & SQL Reporting Querystring Parameters

Posted on 2007-08-08
Last Modified: 2013-12-17
I am working on my first SQL Report and ahve the report designed, and I have my SQL statement with no dynamic parameters done.  Now I want to integrate it into a web site and have the website pass a querystring with the value for a single parameter for the SQL statement to use.  The condition I want to add is District_Name = '<passed value>'.  I have gone through several walkthroughs but have not been able to get it to work.  So, what are the steps for me to add the condition to my where clause in the report so that it reads the value from the query string, and what should that part of the querystring look like?
Question by:SkipFire
    LVL 4

    Expert Comment

    post the code that u use now.

    if you build the SQL inside the applicaiton, you just have to add the where clause to the SQL using normal string concat
    sql = "select * from table where District_name = " + Request.QueryString("District_name")
    sqlcmd.commandText = sql
    sqlcmd.executeReader() ' Or how ever u wish to invoke the query


    sql = "select  * from table where district_name = @param1"
    sqlcmd.commandText = sql
    sqmcmd.parameters.addwithValue("@param1", Request.queryString("District_name"))


    LVL 4

    Author Comment

    Right now I am just doing a response.redirect to the URL of the report, the SQL is currently in the data tab on the report designer.
    LVL 4

    Accepted Solution

    LVL 4

    Author Comment

    Thanks.  I ended up abandoning this line as I was able to convince the client to go to the embedded control on their website.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now