Because there are some limitations (lack of support for design time features etc.) for making
custom controls with SQL Server 2000 Reporting services, working with BarCode in SQL Server 2000 Reporting Services
will be a little complex, of course comparing with using Aspose.BarCode in SQL 2005/2008.
Aspose.BarCode for Reporting Services currently works with SQL Server Reporting Services 2005 and 2008. To make it work with SQL Server Reporting Services 2000, we need to use Aspose.BarCode for .NET product.
Note: There are 2 different BarCode products.
- Aspose.BarCode for Reporting Services: For SQL Server Reporting Services 2005/2008
- Aspose.BarCode: For Programming in .NET frameworks 1.1, 2.x and 3.x and SQL Server Reporting Services 2000
We need to have following environment for using Aspose.BarCode in Reporting Services 2000.
- .NET Framework 1.1
- SQL Server Reporting Services 2000 sp2
- Microsoft Visual Studio 2003
- Aspose.BarCode for .NET (we will use the dll for .NET 1.1)
This article is intended for the customers who wants to use Aspose.BarCode with Visual Studio 2003 and SQL Server Reporting Services 2000. Please refer to http://www.aspose.com/documentation/ssrs-rendering-extensions/aspose.barcode-for-reporting-services/quickstart-tutorial.html if you are planning to use Aspose.BarCode with VS 2005 or later and SQL Server Reporting Services 2005 or later.
Setup Aspose.BarCode for SQL Server Reporting Services 2000
Copy Aspose.BarCode.dll
Copy the Aspose.BarCode.dll to the following SQL Server Reporting Services install directories.
- X:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin\
- X:\Program Files\Microsoft SQL Server\80\Tools\Report Designer
Note: The default location of Aspose.BarCode.dll is C:\Program Files\Aspose\Aspose.BarCode\Bin\net1.1.
Edit SQL Server Reporting Services 2000 config files
Open X:\Program Files\Microsoft SQL Server\80\Tools\Report Designer\ folder. You will find rspreviewpolicy.config file. Open this file in any editor and add the following lines into the <CodeGroup> element.
<policy>
<PolicyLevel version="1">
…….
<CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing">
……..
<!-- Start config for Aspose.BarCode for Reporting Services-->
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="AsposeBarCode" Description="Aspose.BarCode for Reporting Services ">
<IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001005542E99CECD28842DAD186257B2C7B6AE9B5947E51E0B17B4AC6D8CECD3E01C4D20658C5E4EA1B9A6C8F854B2D796C4FDE740DAC65E834167758CFF283EED1BE5C9A812022B015A902E0B97D4E95569EB8C0971834744E633D9CB4C4A6D8EDA03C12F486E13A1A0CB1AA101AD94943236384CBBF5C679944B994DE9546E493BF" />
</CodeGroup>
<!-- End of config -->
</CodeGroup>
</PolicyLevel>
</policy>
Open X:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer folder and add the following lines in rssrvpolicy.config file.
<policy>
<PolicyLevel version="1">
…….
<CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing">
……..
<!-- Start config for Aspose.BarCode for Reporting Services-->
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="AsposeBarCode" Description="Aspose.BarCode for Reporting Services">
<IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001005542E99CECD28842DAD186257B2C7B6AE9B5947E51E0B17B4AC6D8CECD3E01C4D20658C5E4EA1B9A6C8F854B2D796C4FDE740DAC65E834167758CFF283EED1BE5C9A812022B015A902E0B97D4E95569EB8C0971834744E633D9CB4C4A6D8EDA03C12F486E13A1A0CB1AA101AD94943236384CBBF5C679944B994DE9546E493BF" />
</CodeGroup>
<!-- End of config -->
</CodeGroup>
</PolicyLevel>
</policy>
So far, we have copied the Aspose.BarCode.dll file to the SQL Server Reporting Services 2000 folders and also modified the config files. Now, we will create a simple project in Visual Studio 2003 Report Project and include the BarCode in it.
Sample Report Services Project to Demonstrate the usage of Aspose.BarCode in SQL Server Reporting Services 2000
Open Visual Studio 2003 and create a new project of type “Business Intelligence Projects” à “Report Project”.
Add Report
Add a new report to this project. In solution explorer, right click on “Reports”, select “Add” à “Add New Item….” from the menu. Select “Report” from the templates.
Add Dataset
Add a new “Dataset” to the report by selecting <New Dataset> from the Dataset dropdown. You will see the following screen:
Set the name as “Northwind”. From the DataSource dropdown, select “New Data Source”. You will see the following dialog box. Select your SQL Server 2000 instance and the Database “Northwind”. Make sure that you see the “Connection successful” message when you press the “Test Connection” button.
Give the SQL query in the “Query string” textarea. “SELECT * FROM Employees”. Press OK.
Add Reference
Select “Report” à “Report Properties”. Select the “References” tab and add references to the following dlls:
- Aspose.BarCode.dll (default location is is C:\Program Files\Aspose\Aspose.BarCode\Bin\net1.1)
- Select System.Drawing from the “Add Reference” à “.NET” tab.
In “Classes” section, add Class name “Aspose.BarCode.BarCodeBuilder” and add “asposeBarcode” in the corresponding Instance name. We will the instance “asposeBarcode” in the “Code” tab to render the BarCode in the Reporting Services.
Add Code
Select the “Code” tab and add the following lines of VB.NET in the textarea.
Public Function GetBarcodeASP(ByVal code As String) As Byte()
If Not isLicense Then
SetLicense()
isLicense = true
End If
'Set the value to encode
asposeBarcode.CodeText = code
'Set the Code 128 Barcode Symbology
asposeBarcode.SymbologyType = Aspose.BarCode.Symbology.Code128
'Generate the barcode image
Dim ms As New System.IO.MemoryStream
asposeBarcode.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp )
Return ms.GetBuffer()
End Function
Private Shared licenseStr As String = "<?xml version=""1.0"" ………… </License>"
Private Shared isLicense As Boolean = False
Private Sub SetLicense()
Dim ms As New System.IO.MemoryStream
Dim sw As New System.IO.StreamWriter(ms)
sw.Write(licenseStr)
sw.Flush()
Dim lic As New Aspose.BarCode.License
ms.Position = 0
lic.SetLicense(ms)
End Sub
If you have a valid license file, please open it in any editor, copy its contents and past it as the value of licenseStr variable.
If you are using a trial version, just comment out the license code.
We will call GetBarcodeASP function in the value field of the barcode image.
Add Controls/Fields to the Layout
From the Toolbox, drag a new Table to the Layout pane of the report. You will see 3 rows, Header, Detail and Footer automatically added in the table.
From the “Fields”, drag the First Name and Last Name to the detail row as shown in the screenshot below:
In the 3rd column, add an Image from the Toolbox. Click on the Image and select Properties.
Select image/bmp from the MIMEType dropdown.
Select Database as the source.
Set =Code.GetBarcodeASP(Fields!EmployeeID.Value.ToString) as Value.
GetBarcodeASP() is the method that we wrote previously in the Code tab. We are passing the EmployeeID as the CodeText for which the BarCode will be generated. You can pass any valid value as an argument in this function for which you want to generate the BarCode.
Now, click on the Preview, you should be able to see the report preview similar to the screenshot below:
About the author:
Saqib Razzaq
Support Developer
Aspose Guangzhou Team
Reference links:
Product overview for Aspose.BarCode
http://www.aspose.com/categories/visual-components/aspose.barcode-for-.net-and-java/default.aspx
http://www.aspose.com/categories/ssrs-rendering-extensions/aspose.barcode-for-reporting-services/default.aspx
Api & Documents
http://www.aspose.com/documentation/visual-components/aspose.barcode-for-.net-and-java/index.html
http://www.aspose.com/documentation/ssrs-rendering-extensions/aspose.barcode-for-reporting-services/index.html
Support forums
http://www.aspose.com/community/forums/aspose.barcode-for-.net-java-and-reporting-services/193/showforum.aspx