Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

How to create Crystal Reports in asp.net | Crystal Reports Sample Using asp.net

Nov 15, 2011
Introduction:

In this article I will explain how to create crystalreports in asp.net.


Description:

In Previous posts I explained lot of articles regarding Asp.net,
Gridview, SQL Server, Ajax, JavaScript etc. Now I will explain about crystal reports it is standard reporting tool for visual studio by using these we can display reports regarding employee details and display charts etc and crystal reports need minimal coding to display result. 

To implement crystal reports first design the table in database and give name UserInfomation

ColumnName
DataType
UserId
Int(set identity property=true)
UserName
varchar(50)
FirstName
Varchar(50)
LastName
varchar(50)
Location
varchar(50)

After completion of table creation enter some dummy data because we need to use that data to populate reports. Now Open visual studio 2008 and create new website and open Default.aspx page in Design mode after that open Toolbox from that drag and drop MicrosoftReportViewer control from Reporting tab 
After drag and drop MicrosoftReportViewer in your page select ReportViewer control and click on smart tag in right side and select Design a new Report


After click on Design a new report now welcome window wizard will open


Now click on Next button after that new Data Source Configuration Wizard will open in that click on New Connection button to configure database connection.  



Now one window will open to add new connection in that enter Server Name and select authentication type either windows or SQL Server and select database name after fill all the details click on Test Connection if the connection path is correct then that will display Test connection succeeded. After that click ok  


After click ok New database connection added to dropdown now click on Next button

After click Next it will display available Tables, views, Stored Procedures and Functions in DataSource Configuration Wizard in that open Tables section and select required table previously we created table with name UserInformation now I am selecting that table from available list


After click finish our report wizard populate with our selected table now select that table and our Next button


After click Next button it will display options to select Report type either Tabular or Matrix now select Report Type and click Next Button


After click Next Report Wizard display Design the table option with available fields from previous selected table and give options like Page, Group and Details these are used to display the data based on Groupwise etc. Here we are doing simple crystal report sample I am not doing anything simply click on Next Button


After click Next button Report wizard will display option to select Table layout after select required table layout click on Next button


After click Next button Report wizard will display option to select Table style after select required table style click on Next button


After click Next button Report wizard will display Completing the Report Wizard in that enter Report Name and click Finish button


After click Finish button now it will create new report if we open our website Solution Explorer we have chance to see newly created report Report1.rdlc and xsd file in App folder this xsd file contain our selected database table.


After that Now Open Default.aspx page and select ReportViewer and click smart tag in right side in that select Report Type


Once Report1.rdlc selected Open Default.aspx Source code it contains code like this


<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="342px" Width="398px">
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="MySampleDBDataSet_UserInformation" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="MySampleDBDataSetTableAdapters.UserInformationTableAdapter">
</asp:ObjectDataSource>
</div>
</form>
</body>
</html>
If you above code Here we added referece of assembly for Reportviewer that is necessary to run our report perfectly. Now Run your application check the output that would be like this.

Demo


Please give your comments regarding above topic is it ok or not and if you like the post please share it.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

56 comments :

Anonymous said...

now only i am knowning about this topic ,can i know in which cases it is very usefull

PERUSH said...

I want to learn more and more in Dot Net

Amul said...

Thanks a lot Dear.
This has solved my problem.
God bless you.

Bala said...

Thank u

Anonymous said...

thanks u....

Anonymous said...

how to display images in a report which are store in sql server 2005 in the binary format...
presently the image column is displaying error...

Suresh Dasari said...

check this post to display images in crystal report
http://www.aspdotnet-suresh.com/2012/02/dynamically-display-images-in-crystal.html

Anonymous said...

how to upload a crystal report on webserver because when i was trying i got these error

Could not load file or assembly 'CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.


Please reply me also on my email
bharatgunjal2010@gmail.com

thanks in advance......

ssaa said...

thank you sir this info help full lot....keep giving this info...

Anonymous said...

Good topic to learn

Bhojraj singh said...

Tanks buddy for this

shailesh said...

Hello, Great Article.. I link.. Thank you very much. Keep it up. God bless you.

Anonymous said...

Hi,
I an Unable to establish connection with teh database. The error i am getting is:

"An unexpected error has occurred.

Error Message: Could not load type 'Microsoft.VisualStudio.DataDesign.SyncDesigner.SyncFacade.SyncManager'from assembly 'Microsoft.VisualStudio.DataDesign.SyncDesigner.DslPackage,Version=9.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'."

Kindly reply back to yaminisaxena7@gmail.com

Anonymous said...

Thanks a lot ...
it is very easy to understand.

Sandeep said...

Veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
Useful..
Thanks man

Anonymous said...

good example

Anonymous said...

Very good post. Do you have any suggestions to generate report with combination of number of tables with their Foreing_Key and use code behind binding with dataSource. Please let me know how to solv this problem.

Anonymous said...

Hi this contribution is tooooooooo goood thanks man.

Anonymous said...

Superb Tutorial...Really Helpful to me..Thanks Bro...

Anonymous said...

Thinks so much for this tutorial

Anonymous said...

Thanks so much for this tutorial

Anonymous said...

Really helped a lot
thank you very much i was stuck to submit my project because of these report
but now i know how to use it
thank u......

Anonymous said...

Article was so Simple & Useful

Many thanks,
Leo

Anonymous said...

Excellent Article For Beginner
Thanks a lot for sharing.

Balkrushna bapat said...

i like this

Anonymous said...

thanks a lot

Anant Vispute said...

its very good,thanks!!!!!

Anonymous said...

ya.. its very usefull..
given in a specific manner.
it is very helpfull..

thank u.

Anonymous said...

Thanks, Successful work this code..Tc

Anonymous said...

Thanks dude... keep sharing as much as you know....

rajesh g said...

how to bind already exist javascript file into dropdownlist in asp.net? presently its bind html code bt i want asp.net dropdownlist

Nilesh said...

it's very helpfull 4 me
thanks a lot...........

faisal shaikh said...

how should install report viewer ?

Ganesh Khairnar said...

it's very helpfull 4 me
thanks a lot...........

Anonymous said...

thanks sir very useful information.

Anonymous said...

how to dynamically(by coding) create a report through report viewer using asp.net with vb.net.....plz help me

Marcin Sulecki said...

This article describes Reporting Services, not Crystal Reports!

Anonymous said...

ya it is very useful ...10q

Niranjan Das said...

sir how can i generate a report date wise pls help assp.

thank u

Anonymous said...

9965656611

Anonymous said...

very well explained...thnx for help

Anonymous said...

thankx
it is very useful

sathya gariganti said...

yes its very helpfull for me

logesh said...

First of all you are not using Crystal Report. You are using visual studio report viewer. Please correct it

Anonymous said...

Thank you Suresh. Really very useful.

destash13 said...

good but HOW CAN WE SHOW COMPLETE DATA OF GRIDVIEW IN CRYSTAL REPORT?

Nitin Kumar said...

hello Suresh,
I have tried this but when I click on finsh button it gives me a Exception.
Please Help me. to over come this problem.

umesh lade said...

how i can show report without report viewer

Anonymous said...

It's very nice..thanks...i want to know more about crystal report..plese any url.

joe jagadeesh said...

Please Post LINQ TUTORIALS PLEASE

Anonymous said...

Its very helpful buddy.

Dinesh Behera said...

your site are good to understand....

Gadiga Rangamma said...

Hai Suresh Garu....

Excellent Site For Beginner
super...........

dilip prasad said...

Hi sir i want know about crystal report paging and when the create setup file in windows application that time what do so attached for crystal report components plz ...............help me sir

Narsimhareddy venna said...

Hi Sir,
This site is very useful for beginners and Intermediate developers.
Thank you very much

Benny James said...

how to use combination chart using crystal report in asp.net

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.