Wish you Happy New Year.
Today I am going to share a simple way to use SQL Server Reporting Services locally. I am trying to share simple steps for creating report.
I am using North wind database and try to create a sample report which shows customer information.
Here we go
Step 1:- Create a project in my case I am using web project you can choose either web/window. In the project add a type dataset and drag drop customers table on XSD. (You can customize schema according to your need) as shown in below fig.
Step2:- Now add a report (.RDLC)
Step 3:- When you add report then on right side a screen(Just like solution explore) will appear with name “ Web Site Data source “ in this you will find the type dataset which we have added and when you expand the type dataset object you will find all the table schema as show in fig.
- Step 4: Now just drag drop a table from toolbars’ report item. And drag drop column from data source (type data set which shown in step3) to table column which you need to show in report.
Step 5:- Once you done with step4 now next step to call report from “Asp.net”. For this just drag drop Microsoft reporting viewer and do following code.
Below is the code
Dim sqlcon As New SqlConnection(ConfigurationManager.ConnectionStrings(“connectionString”).ConnectionString.ToString())
Dim sqlcmd As New SqlCommand
sqlcmd.CommandText = “SELECT * FROM Customers”
sqlcmd.CommandType = CommandType.Text
sqlcmd.Connection = sqlcon
Dim sda As New SqlDataAdapter
Dim ds As New myDs
sda.SelectCommand = sqlcmd
‘clearing report viewer
‘Create datasource for report
Dim rds As New ReportDataSource()
rds.Name = “myDs_Customers”
rds.Value = ds.Customers
‘assigning report path.
Me.ReportViewer1.LocalReport.ReportPath = “myReport.rdlc”
Now run the page and you will get report .