In this article I will explain how to create crystal reports example in asp.net.
In Previous posts I explained how to install crystal reports in visual studio 2010 and how to create rdlc reports using asp.net and pass parameters to rdlc reports using asp.net. Now I will explain how to create basic crystal reports using asp.net. Crystal Report 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.
ColumnName | DataType |
UserId | Int(set identity property=true) |
UserName | varchar(50) |
FirstName | Varchar(50) |
LastName | varchar(50) |
Location | varchar(50) |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Crystal Report Sample</title> </head> <body> <form id="form1" runat="server"> <div> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" ReportSourceID="CrystalReportSource1" /> <CR:CrystalReportSource ID="CrystalReportSource1" runat="server"> <Report FileName="CrystalReport.rpt"> </Report> </CR:CrystalReportSource> </div> </form> </body> </html> |
![]() |
![]() |
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Crystal Report Sample</title> </head> <body> <form id="form1" runat="server"> <div> <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" ReportSourceID="CrystalReportSource1" /> <CR:CrystalReportSource ID="CrystalReportSource1" runat="server"> <Report FileName="CrystalReport.rpt"> </Report> </CR:CrystalReportSource> </div> </form> </body> </html> |
using System; using CrystalDecisions.CrystalReports.Engine; |
protected void Page_Load(object sender, EventArgs e) { ReportDocument reportdocument = new ReportDocument(); reportdocument.Load(Server.MapPath("CrystalReport.rpt")); reportdocument.SetDatabaseLogon("username","password","SureshDasari","MySampleDB"); CrystalReportViewer1.ReportSource = reportdocument; } |
Imports CrystalDecisions.CrystalReports.Engine Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim reportdocument As New ReportDocument() reportdocument.Load(Server.MapPath("CrystalReport.rpt")) reportdocument.SetDatabaseLogon("", "", "SureshDasari", "MySampleDB") CrystalReportViewer1.ReportSource = reportdocument End Sub End Class |
![]() |
|
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 Email
|
|||
|
|














Subscribe by RSS
Subscribe by Email
48 comments :
No Challenge to this site....This should be the template that every site must follow....
really its very useful
g8t example buddy its easy to understand thanks !
Helped a lot. Thanks
Its a very good example of crystal report....
Is there a way to create a crystal report that can be used in any remote computer system.
Whenever I try to use my crystal report created in my local pc to remote pc having the same database name and feilds I have to recreate the entire crystal report
I have one doubts
my server name is
DARSHAN-PC\SQLEXPRESS
when i write this as a string i am getting error..please help me how to solve this problem
thanks
very very very nice excellent
how to send sms to mobile..
hi suresh from which college you had complited your BE
Dipak
sample project is very help full
thanks
wewewewqe
Thanks SURESH Ji..!!
Nice steps to geneate crystal report
Hi,
This steps of creation is well also run in the browser during the execution in the editor having MS-Dev. kit IDE. But, after this page upload to IIS, the crystal report viewer could not load properly on client PC. Is there any possible setting in Web.Config .... Pls inform...
Thanks in advance...
JP.SIVARAJ
hai.. how can i add my crystal report to templates.. am using crystal report 10...can u help me....
thank you sir, it is good example
i have one query
enable databse login prompting
is it when i have SQL Security
not Windows Security
please reply my query
i mean
string server = @"\SQLEXPRESS";
reportdocument.SetDatabaseLogon("", "", server, "CrystalReport");
in this case i have window integrated security
so i don't have user name or password
thank you
if you have Windows Security then just remove
reportdocument.SetDatabaseLogon("", "", server, "CrystalReport");
hope it will work...
i want to ask Question
my crystal report working fine on local computer
when i uploaded it to server (not published version)
it is give me blank page
please replay me sir
this is my mail
devnet84@yahoo.com
thank you very much
It's very useful to me
Thank u very much
Hi Suresh,
I am new to Crystal Reports,
can u please tell me how the Find button works in the report. If i type "a" and click on that find. it is not doing anything and displaying "End of Search". I have even added the OnSearch click event of that. But no use. Please help me.
Hi suresh ,
this is one good example to create Report generations operation . thanks for your guidance.
Hi Suresh,
I am new to crystal reports, we have a crystal report in that find button fuctionality is not working. Can you please help me. it is crystal 10.0.
DLR
HI I USED THE SAME PROCESS BUT UN ABLE TO MOVE TO THE NEXT PAGE AS WELL AS UNABLE TO EXPORT THE REPORT
hi suresh,
thank you your code helped me in parameter passing in crystal reports.
iam having a problem in crystal reports when iam passing the parameter i am un able to move to the next page as well as export.
iam using vs2010
I used the same code but am getting missing logon parameter error and when i enable log on prompt i get an input box to log on in database..... help me! my e-mail is
urban_hippy@hotmail.com
Hi Suresh....
The above error only appears when i move to the second page,the first page displays fine....
thanx for this hint..
very easy to understand..
hi suresh can u explain me how to display the selected record in a grid view and print the selected record in a crystal report...
I got more help in this your blog....Very fine...easy to understand...I give 1 vote to great site for IT developer....
I think @Suresh ur the best.....ur site is really bombastic......keep itup bro....
I'm using a SAP Crystal Reports Web Viewer to display a CR report. It works perfectly fine in a CR Designer preview, however when I view it in a browser (any) the crosstab does not look as expected:
Can you tell me how to display images through crystal report in viewer. the images are stored in sql database
Hi Suresh this is good exampl but when i run the application to generate report using Crystelreport it is asking Sql Server Credientials ie Uid,Pwd everi time why ples help me
hi sir how to add cssStyle in crystal repot. please help me
Thanks a lot.
Very simple to understand (Step by Step)
Could u pls provide code for how to add button to crystal reportViewer toolbar?
thanks for step by step explanation
Hi,
Suppose we have ever growing database. Can we generate crystal report in real time by choosing some parameters like column names from the database?
thanks
Hi Suresh... Went through your article,found it really useful.Need your help at the start up though.
---------------
When I add a new item (crystal report)to the website,I get a file to my solution explorer with an extension ( .mht ) though it shows a (.rpt) before adding it in the dialogbox where i can rename it and no such gallery to select the template shows.Am I missing out a plugin or something??..
Awaiting your valuable reply :D
Hi Suresh,
Personally, This article very useful to me.I need a help,how to generate Payslip to more than one employee. Kindly give me some ideas like this article.
Thank u so much for your proper reply
thanks,
Revathy C
Hi sir,
This very good and i learn t from this and it is very useful to all like us. so keep it up
thanks.
UMESH KUMAR
Grt....Nice example...!
Good job...thanx..!!
thanx u so much...you give a very good example which is easy to use and understand.
hi suresh..
I have a problem when uploading to the server, .. like this
BC30002: Type 'ReportDocument' is not defined.
Dim reportdocument As New ReportDocument()
Can we use Query to fetch data from multiple table.
If yes , than how?
hi duresh garu i connected database is ado.net dataset but first page is displaying correctly when i ll click for next page it was asking logon failed incorrected parameteres.pls help me
advance thanks
thanks for it. but not display report in web page please help me.