How to create an local report for reporting service in .NET?

In the last few weeks, i started to create reports for my current project. I decided to use the reporting service for my project. It is because it is very powerful than crystal report such as user real time sorting, collaspe and expand, etc..It is very flexible than crystal report.

Reporting Service Interactive Sorting

 ReportingService Expand/Collaspe 

However, it is a new things for me, and i had no idea how to create an report. I spent a lot of time to try it. At last, i have created my first version of reporting engine for reporting service.

OK! Let’s me introduce how to create an report in reporting service at VS.ENT. However, there is so much things. I will show the coding part 1st. Are you ready?!

DataSet dataset = new DataSet(“CustomerSet”);
SqlConnection connection = new SqlConnection(connectionString);

SqlCommand command = new SqlCommand(“Select Name, Age, Address From Customer”, connection);
SqlDataAdapter salesOrderAdapter = new SqlDataAdapter(command);
salesOrderAdapter.Fill(dataset, “CustomerTable”);

ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = dataSourceName;
reportDataSource.Value = dataset.Tables["CustomerTable"];

reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = reportPath;
reportViewer.LocalReport.DataSources.Add(reportDataSource);

reportViewer.RefreshReport();

Is It easy?However, one thing you have been care. It is that the datasource name must been same as the dataset name in the report. Otherewise, it will prompts you an error that the datasource does not exist.

Advertisement

One Response to How to create an local report for reporting service in .NET?

  1. william says:

    man seems you are getting lazy, havent seen you posting for a while :P

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.