Call SQL Server Reporting Services by asp.net in 5 easy step

Hello friends,

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())

            sqlcon.Open()

            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

            sda.Fill(ds, ds.Customers.TableName)

‘clearing report viewer

            Me.ReportViewer1.LocalReport.DataSources.Clear()

‘Create datasource for report

            Dim rds As New ReportDataSource()

            rds.Name = “myDs_Customers”

            rds.Value = ds.Customers

            Me.ReportViewer1.LocalReport.DataSources.Add(rds)

‘assigning report path.

            Me.ReportViewer1.LocalReport.ReportPath = “myReport.rdlc”

            Me.ReportViewer1.LocalReport.Refresh()

 Now run the page and you will get report .

SSRS 
so enjoy.

Thanks

Rajat Jaiswal 

Advertisements

One thought on “Call SQL Server Reporting Services by asp.net in 5 easy step

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s