REPORTING WITH REPORTING SERVICES

Oh ok, so i don’t even need to worry downloading crystal reports for my Visual Studio 2010. Reporting services has been there for a while but did not bother to consider because I have been comfortable with crystal reports, but working on my first project with VS 2010 I had to, because was not seeing crystal reports and had to go through some processes to integrate. So i decided to give Reporting services a try and guys it is very cooooool. Are you a beginner in Reporting Services in Visual Studio, then this will offer you a great help.

Lets go through how to create a report using reporting services and dataset as the data source.

It is assumed you are working with a project with a dataset.

1. Right click to add a new item to your project. On the Reporting tab, choose “Report Wizard” and enter the name of your report in the “name” field provided at the bottom of the “add new item” dialog box. Click on the “Add’ button to proceed.

image

2. In this stage , you choose the data source of your report. You start by entering the name of your Dataset. Take note of the name you enter as you will use it in your code. Select the data source ( the dataset of your project) and then select the table you want to display in your report. Click next to go to the next stage.

image

3.Here, you choose the fields to display on your reports and how to group your records, either by rows or columns. Drag the fields you want to display in the “Values” area. In case you want group your records by rows or columns, drag that field to the “row groups” or “column groups “ respectively. Functions like sum,average, etc can be applied to  fields in the “values’ area. Click next to go the next tab

image 

4. In this stage you choose the layout of your report. Select your layout and click on the next button.

image

5. Select your report style and click on the finish button.

image

 

Your report is then displayed with the selected fields. You can then drag the table to a position of your choice on the report form. You can also insert text and image onto your report as it is done in crystal report.

image

After creating the reports you then have to integrate it into your forms. First you need to add a report viewer. You do this by creating a new form and dragging the report viewer onto it as shown below.

image

After this, you write some small codes to view your report.  First you have to make sure the data table is filled programmatically. Let say at form load event we want to display the report. We start by declaring a procedure that can that accepts the dataset name, report name and the datasource.

   1: public void fillReport(String dataset, String reportname, DataTable loadData)

   2:        {

   3:            this.reportViewer1.ProcessingMode = ProcessingMode.Local;

   4:            //choosing the report source

   5:            this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "/" + reportname + ".rdlc";

   6:            //add the datasource to the report

   7:            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(dataset, loadData));

   8:            this.reportViewer1.RefreshReport();

   9:  

  10:        }

so on form load we fill the data table and call the method above to fill the show the report.

“fillReport("DataSet1", "purchaseSearch", this.dataSet1.land”

Note that the dataset name should be the same as shown in the created report.

Enjoy…

Advertisements

DEPLOYING ASP.NET APPS USING IIS 7

You have finished developing your ASP.net application using VS 2005 in Windows Vista environment and you need to deploy, just go ahead and deploy in the vista environment, you do not have to look for Windows XP before you can do this. Here are few steps to follow to deploy your application using IIS 7 .

  1. First make sure all the components of the IIS server is installed on your system. To do this, Go to Start > Control Panel >Programs and Features and the click on the "Turn Windows features on or off" on the left task pane of the window as shown below.

  2. On the windows feature dialog box that pops up, make sure the Internet Information Service node and all its child nodes are checked as shown below or else get your original Windows Vista CD, check all the nodes and install these features.

  3. To access the IIS Manager after the installation, Go to Start>Control Panel>Administrative Tools >Internet Information Services (IIS) Manager or go to run (Window Key + R) and enter "inetmgr" and you will get an interface like the one below.

  4. Now we are good to go on and deploy our ASP.Net Web Application. Navigate to the Default Web Site Node, then right click on it and choose "Add Application" from the context menu. A dialog box will pop up as shown below. The alias is the name of your website, for example if you enter Ghana, or accra , or kumasi, when accessing your website from your local computer, you will be typing "localhost/Ghana, or localhost/accra, or localhost/Kumasi"

    Click on the "Physical path:" button to browse for the website folder of your application and click on the "OK" button.

  5. A new node with the name you entered in the alias textbox will appear under the "Default Web Site" node. Select the node, and make sure your connection string, default documents are set to the required values. The picture below clarify these

  6. After making the required changes, you are done. Make sure your IIS server is running (you can check this by clicking on the "Default Web Site" node and on the right task pane, under manage web site, make sure the "star" link is disabled else click on it to start the server). Go to your browser and enter your URL, in this case "http://localhost/ghana" or right click your application from IIS GUI and select browse.