Click here to Skip to main content
Click here to Skip to main content

Introduction to Reporting Services - I

By , 10 Jun 2004
 

Introduction

I am writing this article after 2 weeks of using Reporting Services for creating reports. In this two weeks, I have created 14 reports. Two of them have to be written from scratch because of my mistakes. I have decided to write two part of articles about Reporting Services. In the first part, I will show you how to create a simple report and give some advice about Reporting Services Reports. Before starting, I have to make some assumptions about you.

  1. You have successfully installed Reporting Services.
  2. You have some background knowledge about ASP.NET.

First part of the article has a feeling of a walkthrough. If you have a computer which has Visual Studio installed but has no SQL Server installed, when you install Reporting Services, you can only install development components to your machine. Development components will enable you to design reports, after you have installed Reporting Services with development tools. Visual Studio .NET will have a new type of project.

File->New Project-> Business Intelligence Projects -> Report Project. Choose a suitable name and click OK.

After this action, VS.NET creates two folders for you. (Actually, these are not real file folders as you will see if you look at the solution folder, but content holders for your files.)

Every RS report needs a data source to connect to a database. Data sources give information to your report such as database name, user, password and which provider it uses. Actually, they encapsulate ADO.NET connection strings inside them.

Left Click to Shared Data Sources and Add New Data Source

This action opens Data Link Properties dialog box as shown below. Provider tab gives you options to choose which data provider you should use. Understand that RS works internally with Microsoft SQL Server. This means that you have to use SQL Server for using RS. But incoming values for your reports can come from any data source which is supported by ADO.NET such as Access, Oracle and any ODBC compliant database.

Connection tab will allow you to create your connection string; your server name, which user you will use to connect that database, and so on. I did not have to use Advanced and All tabs. But they will allow you to set connection timeout and other connection string properties. You can find more information about connection string properties in MSDN help.

From Data Link Properties, create your connection string. This dialog box creates standard ADO.NET connection string. At this point, if you save all, and go to your project directory (in my machine D:\WorkingFolder\TrialProjects\ReportProject1\ReportProject1\), you will see a file named AdventureWorks2000.rds apart from project and solution files in your directory. Open this file using Notepad etc., it is a standard XML file. Its contents are similar to the snippet shown below:

<?xml version="1.0" encoding="utf-8"?>
<RptDataSource 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>AdventureWorks2000</Name>
<DataSourceID>a0cab8a8-033f-4709-8f22-435e98e8b487</DataSourceID>
<ConnectionProperties>
<Extension>SQL</Extension>
<ConnectString>
  data source=(local);initial catalog=AdventureWorks2000
</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</RptDataSource>

As you see, in your connection string, Integrated Security is defined. If you double click in Shared Data Source, this dialog box is opened:

In this dialog box, if you push Edit button, you will come back to the dialog box you used to create this connection string. Name and types are standard. And connection string is normal ADO.NET connection string. If you want to learn more about connection strings, I advise you to read a introduction article about ADO.NET. In the Credentials tab, you will see this:

This Credentials tab is used for specifying which credential type and how it will be obtained. "Use a specific user name and password" will use a user that has rights to the database, either a database user or NT user. "Prompt for credentials" will ask user to give proper credentials at runtime. The proper credentials can be either database user or NT user as before (if your SQL Server works in mixed mode). I have only used RS with SQL Server, so I do not know how they change with different data providers. Save and look to AdventureWorks2000.rds file again. You will see this:

<?xml version="1.0" encoding="utf-8"?>
<RptDataSource 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>AdventureWorks2000</Name>
<DataSourceID>a0cab8a8-033f-4709-8f22-435e98e8b487</DataSourceID>
<ConnectionProperties>
<Extension>SQL</Extension>
<ConnectString>
  data source=(local);initial catalog=AdventureWorks2000
</ConnectString>
</ConnectionProperties>
</RptDataSource>

As you can see, your password information is not stored in this file. If you use a source control program to share this file among your team-mates, and if your connection string includes a user name and a password, they will have to explicitly set that user name and password if they want to use the same shared data source. Your password and user information are stored in Reporting Services DB and VS.NET as encrypted.

Using shared data sources works better when you have more than one report. You will have to set only one data source's credentials. And you will be able to change that data source very easily. Even you have one report, I advise you to use shared data sources.

Right Click Reports tab in Solution Explorer and Add New Item and add new Report.

You will see three tabs: Data/Layout/Preview. Create a new Dataset as below.

First of all, this dataset is not the same as ADO.NET DataSet if you know ADO.NET. This dataset holds only one set of results. It is similar to DataTable of ADO.NET.

In Query tab, choose a Name. I advise you to give a name here. Because, if you later decide to change the name of your data source, Reporting Services could give errors and you may have to manually update the RDL file (an XML definition used to define your reports). And if you are creating a report with comboboxes to choose parameters, you will have more than one dataset in your report. It will be easier for you if you name it now. 'Data source' is your connection string as I explained. Either you create one for every dataset or you use one shared data source. In 'Command type', you have three choices: text, stored procedure, table direct. Table direct is not supported by SQL Server. And I do not know which databases support this type of command. Text commands are normal queries. If you have a difficulty using stored procedures with Report Wizard, try to use exec [NameOfStoredProcedure]. With this type, wizard will understand your stored procedure. You can later change this text type to stored procedure and remove "exec". I advise you to use stored procedures with your reports. They have a lot of advantages over normal text commands. For example, one of my reports had an error with its query. Its outer join did not work as I supposed it would. And it required me to use inner select. I only had to update the stored procedure in SQL Server. If I have used text as command type, I would have to have updated the report. And believe me, comparing updating stored procedure to updating report definition, updating report definition is more work. You would have to find the RDL file for your report, open VS.NET, open report, etc. etc.

If you click OK now, you will see the query designer as below:

Reporting Services has three types of query designers. One is this graphic query designer which most SQL Server users are familiar from Enterprise Manager. Another is Generic Query Designer. Generic Query Designer has no support for adding tables or selecting fields, but supports all valid SQL. For example, Generic Query Designer supports "CASE" word in SQL command but graphic query designer does not support this. You can create your SQL here, but if you have SQL Server tools installed, I advise you to use them.

Right Click to your Solution and add new project and choose Other Projects-> Database Projects, give a name, and click OK.

You will see a database connection wizard again. Create your connection string as before. After this, you will have two projects in your solution.

We will use this database project to hold our stored procedures and other queries. At this point, add your solution to a source control system. If you do not know what is a source control system, learn it. Believe me, you will need it. Reporting Services is a good product. But as normal with 1.0 of all products, it has some quirks (dare I say bugs). For example, I have changed width of my almost finished report. Reporting Services happily complied with me. But when I tried to run my report: d:\workingfolder\trialprojects\reportproject1\reportproject1\Report1.rdl, the value of the width property for the report ‘body’ is “5010.66mm”, which is out of range. It must be between 0mm and 4064mm.

And Reporting Services gave me a parse error and refused to open my report file. You have two options here. You can roll back to an earlier working version or try to manually edit the RDL definition file. Source control will enable you to roll back to an earlier version very easily. And as a bonus, you will be able to control versions of your SQL queries also.

Right Click to Reporting Services Queries and Choose Stored Procedures. Give a name and click OK.

Wizard will create a stored procedure template for you. I erase comment lines and use this. We will create a very simple stored procedure here with AdventureWorks database, as below:

CREATE Procedure rp_Address
AS
SELECT dbo.Address.AddressID, dbo.Address.AddressLine1,
   dbo.Address.AddressLine2, dbo.Address.City,
   dbo.StateProvince.Name AS StateName,
   dbo.CountryRegion.Name AS CountryName
FROM dbo.Address INNER JOIN
dbo.CountryRegion ON dbo.Address.CountryRegionCode =
   dbo.CountryRegion.CountryRegionCode INNER JOIN
dbo.StateProvince ON dbo.Address.StateProvinceID =
   dbo.StateProvince.StateProvinceID

This SQL will take all addresses from the database. I am trying to give a simple but useful example. You can run your stored procedure in VS.NET, right click and choose Run. Let's go back to our report.

Edit DataSet:

Change Command Type to Stored Procedure, Command Text to rp_Address, and click OK.

Run this dataset. See that our stored procedure works. Choose Layout tab. We have added nothing visual to our report as of now. We shall do so.

Choose View->Toolbox.

This will open the Toolbox menu as above.

Drag and drop a table to the body of your report. Then choose View-> Fields.

This will open Fields box. As you can see, all of the columns in our stored procedure are here.

Drag and drop AddressLine1, AddressLine2 to the Detail part of your table.

Choose Preview. And see that your report runs. Now View-> Solution Explorer. Right Click to Report Project and Properties.

This will open Report Project Properties as below.

Choose Start Item Report1 (only one report exists now), OverwriteDataSourcers true and TargetServerURL to your server (Mine is http://localhost/reportserver/) then click OK.

If you now press F5 or click Debug -> Start, your report will be deployed to the server and run.

License

This article, along with any associated source code and files, is licensed under The Mozilla Public License 1.1 (MPL 1.1)

About the Author

Atilla Ozgur
ISKUR
Turkey Turkey
I started programming in 1991 with Amiga 68000 Assembler. I am a web and database developer proficient in different languages and databases

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionhelp me to get datesmemberveeru.k7-May-08 0:47 
hello sir,
 
can u please help me to get the fallowing based on current date.
 
please provide me the expressions to get these values
 
current month first date
current month last date
 
Previous month first date
Previous month last date
 
current quarter first date
current quarter last date
 
Previous quarter first date
Previous quarter last date
 
current year first date
current year last date
 
Previous year first date
Previous year last date
 
thanks,
veeru.K
Generaldataset xml schema definition as a data sourcememberrychlym8-Mar-06 23:01 
Is there possibility to add xsd-file as a DataSource for the report at creating report definition time? And is it posssible to generate report from the Dataset(,that xsd file describe) further during the runtime?

 
thanks in advance,
Mojmir.
GeneralUse an WebService DataSet as a Reporting Services Data Source.memberjerryvillamizar19-Mar-05 20:33 
Now you can go beyond and expand the capabilities of your SQLRS using WebServices.
 
http://www.rdlcomponents.com/DTE/Default.aspx?sm=a_a3[^]

 
jerryv
GeneralCreate the RDL programmaticallysussAnonymous29-Nov-04 6:47 
The first RDL writer in the market. Generate the XML-RDL (Report Definition Language) file on the fly, programmatically in any .NET application with 100% managed code, with out any knowlegment of the RDL/XML format.
 
http://www.rdlcomponents.com
 

Jerry
Question.rds username and password are stored where?sussJonathan Cogley [MVP C#]13-Aug-04 5:09 
Great article, thank you!
 
You mention "Your password and user information are stored in Reporting Services DB and VS.NET as encrypted."
 
Do you know where or how this information can be retrieved? I am working on an automated deployment script for the reports in our system based on a script in the samples (PublishSampleReports.rss) however when I create a DataSourceDefinition I need the username and password.
 
I see that they are saved in the DataSource table when deployed to the Reporting Server but where are they in the reporting project folder? The only file that looks interesting is the .rptproj file but it looks like some sort of object serialization ... ?
 
Jonathan Cogley [MVP C#]
http://weblogs.asp.net/jcogley
AnswerRe: .rds username and password are stored where?memberAtilla Ozgur16-Aug-04 2:00 
I dont know exactly where they are stored. They are not in projects folder nor in project settings file. I do not have Reporting Services installed in my machine right now. But I would first set up sysinternals regmon and filemon. Then change the password and see if they are saved to localfile system or registry.
 
I mentioned "Your password and user information are stored in Reporting Services DB and VS.NET as encrypted." Since whenever we tried to share .rdl files between our teammates. We had to enter password one more time but never again if did not changed it. Source Safe did not shared password information along with .rdl file info. Therefore I though that it encryped it. Since I could not find any info in that directory. Sorry about vague answer. But right now it is my only answer. If i learn more about this, I will email you.

GeneralGrammar needs some workmemberChris Allen Wright17-Jun-04 2:58 
Who is proof reading these articles? This is the 3rd article in the past month that has had really bad grammar. I love your site and the content, but there must be some mechanisms put in place to edit these articles before they get published to the web.
 
--Chris Wright
GeneralNot fair!memberCoskun Oba4-Jul-04 18:05 
I dont think your comment is fair. You cant expect Codeproject to correct our (non-native English speakers) grammar. You may even go further and ask them not to post our articles because our grammar is not good enough for your standards. Please be my guest and do so. I belive that Codeproject is a world wide community and I hope it stays that way. If you check the articles on this you will see that non-native English speakers have contributed to this site just as much as any.
As conclusion, if you are not happy with our English, you are free not to read it.
STOP DISCOURAGING PEOPLE!
 
Good article Atilla. Thank you for submitting and sharing with us.
 
P.S. I think there should be a mechanism in Codeproject to eliminate comments that discourage people from submitting their knowledge.

 

Life is what happens to you, while you are busy programming.

GeneralRe: Not fair!memberChris Allen Wright7-Jul-04 4:22 
Just because I point out that you are using bad grammar does not in way, shape, or form discourage people from submitting articles into CodeProject. Where did you pull that out of? Good grammar is important to creating a professional web site. Good grammar is important is all aspects of life. If it wasn't, they wouldn't teach it to you in Grammar School.
 
I have no idea who is posting these articles. I don't know if it's the person sitting next to me or someone half way around the world. So to insinuate that I somehow knew the person was not English speaking or outside of the U.S. is just plain ignorant.
 
I am also a developer and a frequent visitor to the site and to insinuate that I would somehow try to discourage someone from submitting an article that could benefit thousands of developers is also ignorant.
 
Again, grammar is very important. If you don't know it, learn it, or get some help such as copying it into a grammar checker/validator, or better yet, CodeProject should be the ones doing this as bad grammar can make a site look unprofessional.
 
They teach you that in Web Usability 101.

GeneralRe: Not fair!memberCoskun Oba7-Jul-04 5:05 
Well, let me explain it the right way.
1. If I was the one posted this article and if someone commented that it had a terrible grammar. I would hesitate to post the second article.
2. Yes, I aggree grammar is very important. I wish we all were able to use the English grammar as well as you do but we cant so please excuse us. Codeproject would probably be the last place on earth I would look for grammatically correct articles. It would be nice but not mandatory to post articles in pefect aggreement with English grammar.
3. I am sure you are also a developer, why else would you visit codeproject. This is where people share their ideas and knowledge. And thats it. When we post articles we try to explain as best as we can but of course as best as our abilities allow.
 
Anyway, I dont think this is such an important issue and I wont keep up with this any further. I would like to believe most developers out there who visit codeproeject, appreciate the authors for contributing and excuse them for any mistakes they do along the way.
 
I hope I could clearly express myself. Please pardon my grammar.Smile | :)
 

Life is what happens to you, while you are busy programming.

GeneralRe: Not fair!memberChris Allen Wright8-Nov-04 6:57 
Coskun Oba wrote:
1. If I was the one posted this article and if someone commented that it had a terrible grammar. I would hesitate to post the second article.
 
1. If you would hesitate, that's good. The hesitation might cause you to have someone else look it over for grammatical errors before posting it out there for the whole world to see. This is good. So you hesitate and wait another day or so, big deal, it's worth it to take more time and do a better job.
 
Coskun Oba wrote:
2. Yes, I aggree grammar is very important. I wish we all were able to use the English grammar as well as you do but we cant so please excuse us. Codeproject would probably be the last place on earth I would look for grammatically correct articles. It would be nice but not mandatory to post articles in pefect aggreement with English grammar.
 
2. Anything is possible. Don't say you can't do something that millions of people have been successful at. Articles don't have to be perfect, just as good as possible and maybe that's not just the author's responsibility. Maybe CodeProject should also get involved to make sure the articles are edited and corrected.
 
Coskun Oba wrote:
3. I am sure you are also a developer, why else would you visit codeproject. This is where people share their ideas and knowledge. And thats it. When we post articles we try to explain as best as we can but of course as best as our abilities allow.
 
3. Yes, and if you don't have the ability to produce good grammar, have someone at CodeProject or somoone else you know look it over. Good grammar is also very important to make sure the message is communicated effectively. It's an important part of the sharing ideas and knowledge.
 

 


GeneralRe: Not fair!memberIAmRanx17-Oct-06 16:10 
Where did you pull that out of?
 

GeneralRe: Grammar needs some workmemberppyrstr6-Jul-04 13:04 
That's right! If you're not an English teacher or a professional linguist, don't waste our time! Wink | ;)
 
Yesterday it worked. Today it is not working. Windows is like that.
- Recent Chinese Proverb
GeneralRe: Grammar needs some workmemberChris Allen Wright7-Jul-04 6:32 
So you have to be a professional linguist or an English teacher to appreciate good grammar?
 
That says a lot about you.
 
As a matter of fact, I have a minor in English and a major in Management Information Systems.
 
Do you even have an education?
 
Obviously someone like you would think that good grammar is a waste of time.
 
And the quote at the bottom of your post is immature and unprofessional and shows your lack of perception and judgement.
 
Wink | ;)
GeneralRe: Grammar needs some workmemberdnh10-Aug-04 9:48 
hey Chris, whazzup? ya thinkin grammar is important, huh? Big Grin | :-D Maybe it is. Anyway, not everybody can afford to waste time learning perfect English. You are qite selfish... I am happy that Attila wrote this article with his not so perfect english instead of learning good grammar, because somebody (me, for example) can now use information in his article.
You wrote: I have no idea who is posting these articles. I don't know if it's the person sitting next to me or someone half way around the world. So to insinuate that I somehow knew the person was not English speaking or outside of the U.S. is just plain ignorant.
Well, maybe you don't know that there is author's name in upper-left corner of every article. With one click you could figure out that Attila is from Turkey. So, who is ignorant, then? That says a lot about you Wink | ;) I don't want to be offensive, so please don't consider it as insult. As you can guess from my English, I am not from English-speaking country and my English is not good... but I think it is good enough to express my ideas. For me it is not difficult to understand Attila's English. So I think that every at least average intelligent person can understand it as well. And there are only developers ( = very intelligent people Big Grin | :-D )... So please forgive as our english
Smile | :)
 
David 'DNH' Nohejl
 
Never forget: "Stay kul and happy" (I.A.)
GeneralRe: Grammar needs some workmemberChris Allen Wright8-Nov-04 6:46 
If you think learning good grammar is a waste of time, you are truly the ignorant one and obviously will stay that way.
 
So you're saying that it's either write developer articles or learn English. He can't somehow do both, right? Uhhh...OK. Now who's the ignorant one?
 
I'm happy he wrote the article also, but that doesn't mean you have to sacrifice one for the other.
 
He also couldn't have someone look it over for grammatical errors right?
 
So because I didn't see the author's name in the upper-left corner of the article, I am somehow ignorant. Uhhh..OK. Get a clue.
 
You call me ignorant and then tell me not to consider it an insult. Man....you need serious help.
 
Grammar is very important or they wouldn't start teaching it at such an early age and continue teaching it throughout your lifetime of schooling.
 
If there are developers from all over the world posting articles to this web site, then it must be the responsibility of the web site owner to edit the articles to make them easier to read and understand. In America, the grammar you use in your writing style and speech is a direct reflection on your intelligence. That's not being selfish, that's being honest.
 
This may not pertain to developers who do not speak or write English…or write it well, but that's why we have proof readers, spell checkers, and grammar checkers. As I said previously and obvously it didn't sink in, I did not know he was from Turkey, but it still doesn't change a damn thing.
 
Good grammar gives more credibility to the web site, the article, and the author. PERIOD!

GeneralRe: Grammar needs some workmemberdnh8-Nov-04 9:21 
yeah I know what PERIOD! means....
bt u don't have to read this Wink | ;)
 
Chris Allen Wright wrote:
You call me ignorant and then tell me not to consider it an insult. Man....you need serious help.
OK, my fault. I should not write "ignorant", but "ignorant of CP". You obviously didn't know so basic thing like how to get detials about article's author. I know there is difference between "ignorant" and "ignorant of". I just didn't know that the second meaning has that "of". So I wrote "I don't want to be offensive, so please don't consider it as insult." Unfortunately you didn't understand. Sorry.
 
Chris Allen Wright wrote:
In America, the grammar you use in your writing style and speech is a direct reflection on your intelligence.
 
Big Grin | :-D not only in America.... but I belive it's not so important HOW you say something, but WHAT do you MEAN ( but they must understand you). Saying bull**t with perfect grammar doesn't make that bul**t something better. Great ideas with formal errors are still usefull... Even if this is me against world, I am not going to surrender... YES I AM IGNORANT. By choice. After everything you wrote, I don't expect you to understand me.
 
Actually, you are right. Good grammar is better then bad grammar. But in real world, there are allways pay-offs. In this case, it's mastering language vs. using it.
 
---------
p.s. I am quite down these days... so every time you see something offensive, imagine something less offensive, plz. Actually I was going to write only "STFU!" I only hope that what I wrote isn't somehow worse.
 
Never forget: "Stay kul and happy" (I.A.)
GeneralRe: Grammar needs some workmemberxoxoxoxoxoxox12-Feb-07 13:53 
you are English Psycho or should i say Psychris?
GeneralSome additional resourcesmemberSteven Campbell15-Jun-04 8:10 
Reporting Services on MSDN is a good resource for those wanting more details.
 
For a quick intro, see Reporting Services Webcast (only works with IE browser).
GeneralGood start...memberKant11-Jun-04 10:43 
Need some formatting for the article.
 
My 5 for the initiation to write an article on Reporting Services.
 

Promise only what you can do. And then deliver more than what you promised.

This signature was created by "Code Project Quoter".
GeneralRe: Good start...memberAtilla Ozgur13-Jun-04 3:11 
Thank you. I have reformatted it again.Smile | :)
 
Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 11 Jun 2004
Article Copyright 2004 by Atilla Ozgur
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid