Showing posts with label SSRS. Show all posts
Showing posts with label SSRS. Show all posts

Wednesday, May 13, 2015

How to Create the SSRS report Template



How to Create the SSRS report Template 

Introduction  

Generally reports are designed like the report header with the logo one left side and the report name in the right side, and report footer contains the page numbers and the page counts these data are common to all the reports. For Example: - The sample report look like 



Issue:- 

This is the sample template design to work with all the reports. There is time taken process for creating the all these same designs for all the reports 

Overcome:-

To overcome this issue we need to create one report template and use the template for all reports.

Creating the Template report in SSRS

Go to solution explorer – Right click on reports – Add – New Item – Select the report template and name it as CommonReportTemplate -- and design the report as show above.
Now copy the CommonReportTemplate.rdl  and past that file to this location 

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

For SQL Server 2005

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

For SQL Server 2008

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

For SQL Server 2012

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

To check the temple add the new template and you will find the other template with name
CommonReportTemplate.rdl  select that report and name it and click on Add .





Read More »

Tuesday, December 23, 2014

How to disable the unwanted SSRS report export formats using asp.net c#

How to disable the unwanted SSRS report export formats using asp.net c#

/// <summary>
        /// Disable Unwanted Export Formats
        /// </summary>
        public void DisableUnwantedExportFormats()
        {
            FieldInfo info;
            foreach (RenderingExtension extension in this.rptname.ServerReport.ListRenderingExtensions())
            {
                if (extension.Name == "EXCEL" || extension.Name == "PDF" || extension.Name == "WORD")
                {
                    //info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                    //if (info != null)
                    //{
                    //    Extension rsExtension = info.GetValue(extension) as Extension;
                    //    if (rsExtension != null)
                    //    {
                    //        rsExtension.Visible = false;
                    //    }
                    //}
                    info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                    info.SetValue(extension, true);
                }
                else
                {
                    info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                    info.SetValue(extension, false);
                }
            }
        }

Call this method in page load method
protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
               

                if (!IsPostBack)
                {
                   
                }
                this.DisableUnwantedExportFormats();

            }
            catch (Exception ex)
            {

            }
        }


Read More »

Tuesday, May 27, 2014

SSRS report error while using in asp.net (The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded)



Error      1              The report definition is not valid.  Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.        

RDLC File Employee.rdlc   
            
Steps to solving this error

Step 1:- Remove or Delete all Shared Data Sets in the SSRS reports (Share datasets is the 2010 format that will work with visual studio 2012 only)


Step 2:- Converting the share dataset to local datasets

Step 3:- Right Click the Employee.rdl FileàView Codeà

On the top report tag u have to update

Previous

<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">

After

<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2008/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">

Replace 2010 with 2008 in the above code

Step 4:- Ctrl+ Find for “ReportSections” and remove the tags in that code

  <ReportSections>
    <ReportSection>
    </ReportSections>
  </ReportSection>


Step 5:- Run the code and check


For any clarifications or queries please don’t hesitate to call or Email 

Phone :- + 91-9492179390


Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com 

Read More »

Simple way to creating the SSRS reports (Very Basic & Very Easy)

Very very simple steps with full of step by step screen shorts

Step 1:- Open Microsoft visual studio 2008

File à New Project àReport Server Projectà Name it as “SampleSSRSReport”



Empty solution explorer will display like

Step 2:-Right Click the shared data source àAdd New Data Source

Screen will display like



Click Edit button for configure the data base connection

Give all the required parameters

Make Shure check the check box Save mu password (Because wile accessing the report without save that password it will ask every time)


To check the connection successful click the Test connection button

If connected successfully message will show like



Step 3:- Creating the Report


Right Click the ReportsàAddàNew ItemàSelect Report TempleteàName it as Employee.rdl


Click Add empty report is created

Step 4:- Configure the data source

Go to right side click the Report Data



Configure the shared dataset to this report

Right click the Data sourceàAdd data Sourceà Follow the below screen below





Step 5:-

Now creating the DataSet for the Report binding

Data SetàAdd Data SetàFollow the screen bello for proper understanding





First of all I will show Query type with Text



Click OK





With Query Type Store procedure



Click ok

Right click the empty design



InsertàTable à



Mouse over on the table it will show like to bind the data set columns to the table


Like that configure the required fields

Configure the parameter as dropdown

Right click the parameter àParameter propertiesà Follow below screen




Create One more dataset for drop down


Click Preview button








That sol the simply creating the SSRS reports


For any clarifications or queries please don’t hesitate to call or Email

Phone :- + 91-9492179390

Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com

Read More »

Monday, May 26, 2014

Configuring the SSRS Reports to Asp.Net for Locally

Step 1:- Creating the one sample .rdlc file report from SSRS templete
Step 2:- Add Reference to the project “Microsoft.ReportViewer.WebForms

<%@ Register
Assembly="Microsoft.ReportViewer.WebForms,
Version=10.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
       Namespace="Microsoft.Reporting.WebForms"
TagPrefix="rsweb" %>

Step 3:-Add this report tag

<rsweb:ReportViewer
ID="ReportViewerForCSDRS"
runat="server"
ShowPrintButton="true"
       Font-Names="Verdana"
       Visible="true"
       Font-Size="8pt"
       InteractiveDeviceInfos="(Collection)"
       WaitMessageFont-Names="Verdana"
       WaitMessageFont-Size="14pt"
       Width="100%"
       Height="600px"
       ShowBackButton="False"
       ShowDocumentMapButton="False"
       ShowFindControls="False"
       ShowParameterPrompts="False"
       ShowExportControls="True">
</rsweb:ReportViewer>


Step 4:- Full the dataset from the data base

ClsRptPL objPL = new ClsRptPL();
objPL.FromDate = Convert.ToDateTime(Request.QueryString["FromDate"]);
objPL.ToDate = Convert.ToDateTime(Request.QueryString["ToDate"]);


DataSet ds = new DataSet();

ds=  (fill the data set)

Step 5:- Bind data set to the report datasource

ReportDataSource reportDSHeader = new ReportDataSource("DataSetName", ds.Tables[0]);
ReportViewerForCSDRS.LocalReport.DataSources.Clear();
ReportViewerForCSDRS.LocalReport.EnableExternalImages = true;
ReportViewerForCSDRS.LocalReport.DataSources.Add(reportDSHeader);

Note: “DataSetName” Here displaying the name of the dataset is same as the Report Dataset name while creating the RDLC report

Step 5:- With Parameters report

Here we configure the report parameters

Make Shure that the parameter name is as same as the report parameter name



ReportParameter[] repparams = new ReportParameter[2];

repparams[0] = new ReportParameter();
repparams[0].Name = "FromDate";
repparams[0].Values.Add(objPL.FromDate.ToString());

repparams[1] = new ReportParameter();
repparams[1].Name = "ToDate";
repparams[1].Values.Add(objPL.ToDate.ToString());

ReportViewerForCSDRS.LocalReport.SetParameters(repparams);

ReportViewerForCSDRS.LocalReport.ReportPath = Server.MapPath("ReportRDLC\\PaymentReceipt.rdl"); 

ReportViewerForCSDRS.LocalReport.Refresh();
ReportViewerForCSDRS.ShowExportControls = true;
ReportViewerForCSDRS.ShowReportBody = true;
ReportViewerForCSDRS.ShowToolBar = true;

NOTE: Make sure to add this code in the web config file 

 <system.webServer>
  <handlers>
    <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

</handlers>
</system.webServer>

---------------------

<system.web>
 <compilation debug="true" targetFramework="4.5">

  <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   </buildProviders>


  <httpHandlers>
   <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        validate="false" />

   </httpHandlers>

 </compilation> 

</system.web>


Also Export for PDF and Excel

        Warning[] warnings;
        string[] streamids;
        string mimeType, encoding, extension;
        string ReportName = string.Empty;

protected void imgpdf_Click(object sender, ImageClickEventArgs e)
        {
            //extension = ".pdf";
            ReportName = "SampleReceipt";
            byte[] bytes = ReportViewerForCSDRS.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
            Response.ContentType = "application/excel";
            Response.AddHeader("Content-disposition", "filename=" + ReportName + "." + extension);

            Response.OutputStream.Write(bytes, 0, bytes.Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.Flush();
            Response.Close();
        }

protected void imgexcel_Click(object sender, ImageClickEventArgs e)
        {

            byte[] bytes = ReportViewerForCSDRS.LocalReport.Render("EXCEL", null, out mimeType, out encoding, out extension, out streamids, out warnings);
            Response.ContentType = "application/excel";
            Response.AddHeader("Content-disposition", "filename=" + ReportName + "." + extension);

            Response.OutputStream.Write(bytes, 0, bytes.Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.Flush();
            Response.Close();
        }




For Complete Proper look and fee for the SSRS Report design in aspx


<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .overlay
        {
            position: fixed;
            z-index: 98;
            top: 0px;
            left: 0px;
            right: 0px;
            bottom: 0px;
            background-color: #EBEBEB;
            filter: alpha(opacity=80);
            opacity: 0.8;
        }
        #ctl00_ContentPlaceHolder1_rptCommon_ctl05
        {
            background-color: White !important;
            background-image: none !important;
            text-align: left !important;
        }
        #P91bea07e815a4c2187960cfbaecf3a3e_1_oReportCell
        {
            width: 10% !important;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2 class="module-title" align="center">
        <asp:Label runat="server" ID="lblScreenHeader" Text="" Width="1090px" Font-Size="Medium"
            Style="text-decoration: underline" /></h2>
    <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" EnablePageMethods="true"
        EnablePartialRendering="true" LoadScriptsBeforeUI="true">
    </asp:ScriptManager>
    <table align="right">
        <tr align="right">
            <td>
                <asp:ImageButton ID="imgexcel" runat="server" ImageUrl="~/images/excel.jpg" Width="30px"
                    Height="30px" OnClick="imgexcel_Click" ToolTip="Export to Excel" />
                <asp:ImageButton ID="imgpdf" runat="server" ImageUrl="~/images/pdf.png" Width="30px"
                    Height="30px" OnClick="imgpdf_Click" ToolTip="Export to Pdf" />
            </td>
        </tr>
        <tr align="right">
            <td>
                &nbsp;
            </td>
        </tr>
        <tr align="center">
            <td>
                <div style="width: 1103px; overflow:auto;">
                    <rsweb:ReportViewer ID="rptCommon" runat="server" ShowPrintButton="true" Font-Names="Verdana"
                        Visible="true" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
                        WaitMessageFont-Size="14pt" Width="100%" Height="100%" ShowBackButton="False"
                        ShowDocumentMapButton="False" ShowFindControls="False" ShowParameterPrompts="False"
                        ShowExportControls="True" SizeToReportContent="true" ShowPageNavigationControls="True"
                        ShowToolBar="False">
                    </rsweb:ReportViewer>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>


Execute the project and check

For any clarifications or queries please don’t hesitate to call or Email

Phone :- + 91-9492179390


Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com 
Read More »