Using Forms Control with SSRS
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 requirements must be met:
- Visual Studio .NET 2003 or 2005 should be installed.
- Access will be needed to 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,
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.
Note: When using Reporting Services 2005, IDAutomation recommends
Reporting Services Barcode CRI to create barcodes on reports.
- Install the IDAutomation .NET Forms Control on a computer. Note
the installation location.
- 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.
- Copy the control to the Report Designer folder.
The default location of the Report Designer is
C:\Program Files\Microsoft SQL
- 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.
- 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
- If adding the custom assembly to an existing report, skip to
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
Name the sample report appropriately in the Name box.
- Select the data source. For this example, the Northwind database
Ensure that the user Edits the connection string to properly connect
to the database. Click Next.
- Create the query string for generating the report by using the
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.
- Click Next on the Design Query Wizard.
- Choose the type of report (tabular or Matrix) to create
and click Next.
- Leave the default values for the grouping of the report and
- Select the style of the table and click Next.
- 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
- 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.
- 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.
- 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.
- Click the button containing three dots next to the Assembly
- Click the Browse button on the Add Reference dialog
Navigate to the location of IDAutomation.LinearBarcode.dll. Select
the file and click Open.
Click OK on the Add Reference Dialog.
- 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:
- 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.
- 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)
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
bitmapBytes = stream.ToArray
- 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.
- Source - Select Database from the list. This signifies that
the value for the barcode will be pulled from a database field.
- MIMEType - Select image/jpeg from the list. This signifies
the format of the image used within an email.
- BackgroundRepeat - Select NoRepeat from the list. This ensures
that only one image is placed in the text box.
- 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.
- Click the Preview tab to ensure that a barcode
- 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
- If the user wishes to deploy the solution to the Report Server,
click Build | Deploy Solution.