locked
Opening Datasource RRS feed

  • Question

  • User-305496339 posted

    Hi Friends,

     

    I was wondering when you use the report viewer control in a visual studio web application to render reports locally, you will add the control to a web form and then you will see the Report Data window and in there you will create a Data source and datasets. My question is, after you have created a data Source, is there a way to go back and view it or edit it? Thank You !!!

    Tuesday, August 6, 2019 5:43 PM

Answers

  • User-1038772411 posted

    Hello rkrex

    please refer below link how to add,edit,delete fields in the report data pane

    https://docs.microsoft.com/en-us/sql/reporting-services/report-data/add-edit-refresh-fields-in-the-report-data-pane-report-builder-and-ssrs?view=sql-server-2017

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 5:22 AM
  • User288213138 posted

    Hi rkrex,

    after you have created a data Source, is there a way to go back and view it or edit it

    According to your description, I couldn’t understand your requirement clearly.

    Do you mean you want to change the reportviewer control content?

    if so, you need to change the report.rdlc. because the content of  reportviewer determined by report.rdlc.

    If I misunderstand your requirement, please post more details information about your requirement.

    Here is a video about how to use the reportviewer in web form.https://www.youtube.com/watch?v=QMWB5lBamuY

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 10:51 AM
  • User288213138 posted

    Hi rkrex,

    open this Data Source to find out the stored procedure, sql statement, or table the data is coming from

    It depends on the code in your project to see which database you're linking to and what sql statement did you use.

    You can look for connection strings, some database queries in your project.

    Best regards,

    sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 9, 2019 10:39 AM
  • User288213138 posted

    Hi rkrex,

    Since I don't know your code, I can only give you an example.

    such as this Report viewer control demo:https://www.aspsnippets.com/Articles/ASPNet-Report-Viewer-control-Tutorial-with-example.aspx

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600">
        </rsweb:ReportViewer>
        </form>
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
            Customers dsCustomers = GetData("select top 20 * from customers");
            ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(datasource);
        }
    }
     
    private Customers GetData(string query)
    {
        string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        SqlCommand cmd = new SqlCommand(query);
        using (SqlConnection con = new SqlConnection(conString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;
     
                sda.SelectCommand = cmd;
                using (Customers dsCustomers = new Customers())
                {
                    sda.Fill(dsCustomers, "DataTable1");
                    return dsCustomers;
                }
            }
        }
    }

    The connection string tells you which database to connect to, and the query command tells you which table(or stored procedure) in the database to query.

    If you haven't solved the problem, please post all your code.

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 1:55 AM

All replies

  • User-1038772411 posted

    Hello rkrex

    please refer below link how to add,edit,delete fields in the report data pane

    https://docs.microsoft.com/en-us/sql/reporting-services/report-data/add-edit-refresh-fields-in-the-report-data-pane-report-builder-and-ssrs?view=sql-server-2017

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 5:22 AM
  • User288213138 posted

    Hi rkrex,

    after you have created a data Source, is there a way to go back and view it or edit it

    According to your description, I couldn’t understand your requirement clearly.

    Do you mean you want to change the reportviewer control content?

    if so, you need to change the report.rdlc. because the content of  reportviewer determined by report.rdlc.

    If I misunderstand your requirement, please post more details information about your requirement.

    Here is a video about how to use the reportviewer in web form.https://www.youtube.com/watch?v=QMWB5lBamuY

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 10:51 AM
  • User-305496339 posted

    Sorry for the misunderstanding. I tried to be as clear as possible regarding what the issue is that I am trying to resolve. Anyway, maybe I should preface my question with I have to maintain a preexisting system that is using local reports or rdlc files. Obviously the person that designed the reports has created a Data Source, and I was just wondering how do I "open this Data Source to find out the stored procedure, sql statement, or table the data is coming from. The rdlc file does show me where the data is coming from that the datasets are using, but it doesn't show anything in regards to the Data Source. Thanks for your help !!!!

    Wednesday, August 7, 2019 2:04 PM
  • User288213138 posted

    Hi rkrex,

    open this Data Source to find out the stored procedure, sql statement, or table the data is coming from

    It depends on the code in your project to see which database you're linking to and what sql statement did you use.

    You can look for connection strings, some database queries in your project.

    Best regards,

    sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 9, 2019 10:39 AM
  • User-305496339 posted

    How would a connection string tell me what the source of the report data is, in regards to a sql ststement, stored procedure, or a table? It is my understanding that a connection string would only tell me what database the report is using.

    Friday, August 9, 2019 2:43 PM
  • User288213138 posted

    Hi rkrex,

    Since I don't know your code, I can only give you an example.

    such as this Report viewer control demo:https://www.aspsnippets.com/Articles/ASPNet-Report-Viewer-control-Tutorial-with-example.aspx

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="600">
        </rsweb:ReportViewer>
        </form>
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
            Customers dsCustomers = GetData("select top 20 * from customers");
            ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(datasource);
        }
    }
     
    private Customers GetData(string query)
    {
        string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        SqlCommand cmd = new SqlCommand(query);
        using (SqlConnection con = new SqlConnection(conString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;
     
                sda.SelectCommand = cmd;
                using (Customers dsCustomers = new Customers())
                {
                    sda.Fill(dsCustomers, "DataTable1");
                    return dsCustomers;
                }
            }
        }
    }

    The connection string tells you which database to connect to, and the query command tells you which table(or stored procedure) in the database to query.

    If you haven't solved the problem, please post all your code.

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 1:55 AM