, Inc., Computers Hardware, Software & Services, Tampa, FL Contact IDAutomationView your cart in the IDAutomation Store  
Home > Barcode Components > .NET Windows Forms Controls > Microsoft Reporting Services:

Using Forms Control with SSRS

Barcode Solution for Microsoft® Reporting ServicesThis tutorial was created for SQL Server 2000 or 2005 Reporting Services and Visual Studio 2003 or 2005. When using Reporting Services 2005 or greater, IDAutomation recommends using the Reporting Services Barcode CRI to create barcodes on reports.

A Reporting Services Image Control or Text Box Control can be linked to the IDAutomation .NET Barcode Forms Control to create a valid image of a barcode for display in a report. This tutorial will show how to include the IDAutomation .NET Windows® Forms Control in a project and how to create a report using the control. This example will show how to build a report based on the Customers table of the Northwind database. The report will include the database fields of CompanyName, CompanyID, and ContactName. The BackgroundImage property of a text box control in the report will be added and set to represent the barcode. Once the report is created, the security settings for the deployment environment must be configured to allow custom assemblies to run.

To use this tutorial, the following prerequisites must be satisfied:
  • Visual Studio .NET 2003 or 2005 should be installed.
  • Access will be needed for a SQL Server 2000 SP 3a database. (This tutorial will make use of the Northwind database that is included with the SQL Server installation.)
  • Reporting Services must be installed.
  • The IDAutomation .NET Windows Forms Control must be purchased and downloaded, or download an evaluation version of this control. When using IDAutomation .NET Forms Controls with Reporting Services, at least one (1) Developer License must be purchased.

Reporting Services Tutorial

Note: When using Reporting Services 2005, IDAutomation recommends using the Reporting Services Barcode CRI to create barcodes on reports.

  1. Install the IDAutomation .NET Forms Control on a computer. Note the location of the installation.
  2. The Forms control will need to be copied to two specific places so that Reporting Services can find the control. The name of the DLL is IDAutomation.LinearBarCode.dll.
    1. Copy the control to the Report Designer folder. The default location of the Report Designer is C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer.
    2. The control also needs to be copied to the Report Server directory so that it is available for deployment. The default location of that directory is C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin.
    3. If Visual Studio 2005 is being used, the IDAutomation.LinearBarCode.dll also needs to be placed in the default location, C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies
  3. If adding the custom assembly to an existing report, skip to Step 13.
    Create a report: Select File | New | Project from the Visual Studio .NET 2003 (VS.NET) IDE menu.
    In the New Project dialog, highlight Business Intelligence Projects in the Project Types box and Report Project Wizard in the Templates box.
    Name the sample report appropriately in the Name box. Click OK.
    Select Project Type in the Visual Studio.NET IDE menu.
  4. Select the data source. For this example, the Northwind database is used.
    Ensure that the user Edits the connection string to properly connect to the database. Click Next.
    Select the corresponding Data Source with the Report Wizard in Microsoft Reporting Services.
  5. Create the query string for generating the report by using the Query Builder.
    Add the Customer table to the query by right-clicking the upper pane in the query builder and selecting Add Table.
    Highlight Customers and click Add and Close.
    Drag the CustomerID, CompanyName, and ContactName fields into the query. Click OK.
    Using Query Builder in MS Reporting Services to select the corresponding tables.
  6. Click Next on the Design Query Wizard.
  7. Choose the type of report (tabular or Matrix) to create and click Next.
  8. Leave the default values for the grouping of the report and click Next.
  9. Select the style of the table and click Next.
  10. Select the Report Server (The user will want to leave the default value. This was setup during Report Services installation) and the folder for the deployment of the compiled report. Click Next.
  11. Name the report Barcode Company ID and click Finish. The report will now be in Layout mode. The user may run the report to get an idea of how the output will be displayed. The following steps will add the barcode image to the report.
  12. Right click the last column in the table.
    Select Insert Column to the right.
    Label the column Barcode ID by typing directly into the column header.
    Inserting a Barcode ID column into Microsoft Reporting Services.
  13. Click on the body of the report. This will activate the Report menu in the VS .NET IDE.
    Click the Report Menu | Report Properties.
    Click the References tab. At this point, IDAutomation.LinearBarCode.dll will be added to the report project.
  14. Click the button containing three dots next to the Assembly column.
  15. Click the Browse button on the Add Reference dialog box.
    Navigate to the location of IDAutomation.LinearBarcode.dll. Select the file and click Open.
    Click OK on the Add Reference Dialog.
  16. Select the class name containing the data encoding functions. This value is pulled directly from the assembly file. An instance name is required so that the object can be referenced in the code to create the image. The values for these fields may be pulled directly from the image below:
    Reporting Services Properties
  17. In order to use the IDAutomation Linear Forms Control in the report, the System.Drawing and System.Windows.Forms assemblies need to be included in the project. To include these assemblies, click Add Reference again and select System.Drawing.dll and System.Windows.Forms.dll from the list of available assemblies. Note: Do not click OK. The next step uses the Report Properties screen.
    Reporting Services Assemblies
  18. The Linear Forms Control can now be used in the report. The most common use of the control is to use the BMPPicture property to create an image that can be included in the report. The following code can be placed in the Code tab of the Report Properties to create a function, which returns a property representing a byte stream of the image:

    Public Function GetLinear(Code As String) as Byte()
     dim stream as System.IO.MemoryStream = New System.IO.MemoryStream
     dim bitmapBytes as Byte()
     objLinear.SymbologyID = IDAutomation.Windows.Forms.LinearBarCode.Barcode.Symbologies.Code39
     objLinear.Resolution = 2
     objLinear.ResolutionCustomDPI = 96
     objLinear.DataToEncode = Code
     objLinear.XDimensionMILS = 11
     objLinear.NarrowToWideRatio = 3
     objLinear.CheckCharacter = false
     objLinear.BarHeightCM = 2.54
     objLinear.ShowText = false
     objLinear.ApplyTilde = true
     objLinear.BMPPicture.Save(stream, System.Drawing.Imaging.ImageFormat.jpeg)
     bitmapBytes = stream.ToArray
     Return bitmapBytes
    End Function

  19. Set the Barcode ID column to display the image of a barcode representing the customer ID value returned by the GetLinear () function created above. This is done by setting the values in the BackgroundImage property of the text box in the BarcodeID column.
    1. Source - Select Database from the list. This signifies that the value for the barcode will be pulled from a database field.
    2. MIMEType - Select image/jpeg from the list. This signifies the format of the image used within an email.
    3. BackgroundRepeat - Select NoRepeat from the list. This ensures that only one image is placed in the text box.
    4. Value - =code.GetLinear(Fields!CustomerID.Value). Tells the report to use the GetLinear function found in the code module of the report properties and to use the value in the CustomerID field of the database table.
  20. Click the Preview tab to ensure that a barcode is returned.
    Reporting Services Report complete with barcode.
  21. Before deploying the report to the Web server, the user may have to update the security settings of the .NET Framework to give the IDAutomation.linearbarcode.dll assembly permission to run. Microsoft has documented these configuration steps in Knowledge Base article 842419.
  22. If the user wishes to deploy the solution to the Report Server, click Build | Deploy Solution.
Related Information:
 © Copyright 2014, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.