Page 1
• Home
• Ask a Question
• Jobs
• Projects
• Forum
• Submit Tutorial
• Latest Tutorials
• Subscribe in a reader
Search
Your first VB.NET Crystal Reports - A step by step guide
By: Issac Emailed: 355 times Printed: 534 times
Crystal Report is an application which can generate various reports from different data
sources, we can create reports, print and preview those report using it, It is compatible with almost a
developing platforms and databases, In this article you can find useful resources for generating
reports from VB.NET with Crystal Report.
We can now see how to create a sample Database and Tables and data. First we have to create a
database. Give the database name as "crystaldb"
Create a DataBase "crystaldb"
In the crystaldb database, let us create three tables OrderMaster, OrderDetails, Product.
Page 2
OrderMaster
1. OrderMaster_id
2. OrderMaster_date
3. OrderMaster_customer
4. OrderMaster_createduser
OrderDetails
1. OrderDetails_id
2. OrderDetails_masterid
3. OrderDetails_productid
4. OrderDetails_qty
Product
1. Product_id
2. Product_name
3. Product_price
Now that you have a database you can start your first VB.NET Crystal Reports.
All Crystal Reports programming samples in these tutorials are based upon the following database
(crystaldb, the one we created through the previous article).
Open Visual Studio .NET and select a new Visual Basic .NET Project.
Page 3
Create a new Crystal Report for Product table from the above database crystalDB. The Product
Table has three fields (Product_id, Product_name, and Product_price).
From the main menu in Visual Studio select PROJECT-->Add New Item. Then Add New Item
dialogue will appear and select Crystal Reports from the dialogue box.
Page 4
Accept the default settings and click OK.
Next step is to select the appropriate connection to your database. Here we are going to select
OLEDB connection for SQL Server
Select OLE DB ( ADO ) from Create New Connection.
Page 5
Select Microsoft OLE DB Provider for SQL Server.
Page 6
Next screen is the SQL Server authentication screen. Select your Sql Server name, enter userid,
password and select your Database Name. Click next, Then the screen shows OLE DB Property
values, leave it as it is, and click finish.
Then you will get your Server name under OLEDB Connection from there select database name
(Crystaldb) and click the tables , then you can see all your tables from your database.
From the tables list select Product table to the right side list.
Page 7
Click Next Button
Select all fields from Product table to the right side list.
Page 8
Click Finish Button. Then you can see the Crystal Reports designer window. You can arrange the
design according your requirements. Your screen looks like the following picture.
Page 9
Now the designing part is over and the next step is to call the created Crystal Reports in VB.NET
through Crystal Reports Viewer control.
Select the default form (Form1.vb) you created in VB.NET and drag a button and
CrystalReportViewer control to your form.
Select Form's source code view and put the code on top
Imports CrystalDecisions.CrystalReports.Engine
Put the following source code in the button click event
Imports CrystalDecisions.CrystalReports.Engine
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Page 10
End Sub
End Class
NOTES:
cryRpt.Load ("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
The Crystal Reports is in your project location, there you can see CrystalReport1.rpt. So give the
full path name of report here.
After you run the source code you will get the report like this.
Hope this article helps you to create your first Crystal Reports.
Page 11
If this tutorial doesn't answer your question, and you have a specific question, just ask an
expert here. Post your question to get a direct answer.
2009-02-21
Comments(21)
1. Hi ,
Is there any way to export contents of datagridview to crystal report?. bcos i have some data which is
displayed in the gridview but not in the dataset or table.
By: Nithya Duraiswamy at 2009-03-03 21:32:05
Show Comment
2. Hi Nithya,
yes you can do that see the tutorial on How to export from DataGridView to excel using VB.net at
http://www.java-samples.com/showtutorial.php?tutorialid=1054
By: Ramlak at 2009-03-04 01:20:01
Show Comment
Page 12
3. Hey is there any way to export datagrid to crystal reports. Please advice me on this
By: Anu at 2009-05-08 13:11:48
Show Comment
4. can i have sample of java programming that has database connection and manipulation on SQL 200
and MS Access?
Thanks
By: piolo at 2009-05-31 18:53:25
Show Comment
5. the above is perfect, but when i hit the export button, it opens the save as window, it defaults to .rpt as
the save as type, how can i set this to XLS and still allow the user to save as normla, i.e set file name
and location themselves, as I have been looking into this and a lot of people are suggesting adding a
button and using the export options, but I don’t want that I still want the user to control where/what
they save, it just want it to default to excel for them. Any ideas?
By: CH at 2009-06-02 03:01:34
Show Comment
6. Hi,
i tried this way.that works perfectly.but i make the setup of the project & install it.there, report doesn't
display...it shows an error message...is there any additional software needed to display report???wat's
the problem??pls help me...
By: indu at 2009-06-08 03:13:51
Show Comment
7. How can I send parameter to crystal report?
Page 13
By: Mark at 2009-10-14 03:41:36
Show Comment
8. hi! this coding is very helpful for me thanks .
By: bhuvaneshwari at 2009-10-18 23:52:58
Show Comment
9. hi,
my problem is.......
i use vb.net 2005 i want to put any no to data grid from the user and perform the arithmetic operation
on it such as.....
column1 column2 co lumn3
5 * 2 10
input 5 and 2 from user in column 1 and column 2 and calculate the value of it in 3rd column
By: Anirban at 2009-10-25 10:15:13
Show Comment
10. hay is there any way to perform operation or calculation
directly on crystal reports, which was not done in dataset.
like can i count number of presence of a person in a particular month directly in reports?
By: neha at 2009-11-20 08:29:45
Show Comment
11. hello,
i have to connect the crystal report with the report source dynamically. Is there any facility to connect
Page 14
the report dynamically?
By: shanmugaraj at 2010-03-03 04:08:30
Show Comment
12. very good tutorial..
By: shobhit at 2010-05-04 12:17:41
Show Comment
13. hi this is very helpful........thank you very much
By: sumalatha at 2010-06-07 02:16:37
Show Comment
14. hey dude
im using vb.net 2008 and sql server 2005
i followed the steps
but when i hit show button the report viwer only show the field names its not showing the data in a
table
i made a report of a single table to show all data of that table as u did
By: Haseeb ur Rehman at 2010-11-12 02:08:48
Show Comment
15. Hi,
My problem is that how to connect the report with my access database by using a relative path..u know
wat i mean.. a path that will run on any other PC..
because actually when i run my program on another PC, it is asking for the database..and i need to
reconnect the database..but when i will submitt it will be wrong
Page 15
so i need to know a way to connect using a relative path
thanks hope it is well explained
By: Twahie at 2011-03-21 05:31:06
Show Comment
16. Hi,
As you shown here that we have to give the full path of our crystal report but what the problem here is
that if you switched to another system there might not be having the same path. So what we have to
do is have to change the paths of all the reports. What i wish is that is there any way we can give
relative path instead of absolute path? How?
By: Keyur at 2011-04-05 03:30:12
Show Comment
17. sir,
my project is in asp.net so is there any reports to be generated for asp projects .please reply sir
By: mohsin at 2011-04-14 06:25:59
Show Comment
18. can you clearly reveal how to create crystal reports and how to make alignments in crystal reports in
vb6....?
By: halim at 2011-07-02 00:28:48
Show Comment
19. Hi,
My problem is with daybook. In table , The ledgername is 'Purchase' , But in crystal report, I want 'By
Page 16
Purchase',, How can i get it sir?
Thanks in advance....
By: Priyesh at 2011-07-06 06:34:33
Show Comment
20. Hi sir !
I have two Crystal Report, Named Crystal1 and crystal2,
Is it possible that the CrystalReportViewer can view two Crystal report .. ? and how ? im using Vb.net
2008..
By: Anderson Abad at 2011-07-20 03:34:51
Show Comment
21. I am using VS2010 & SAP for crystal report. I have done what you posted.
But I did it with my database. A table was selected like your post.
It show only column name, does not show the value of row. Some color name & date was shown here. I
have tried for another tables. It's act same. I don't understand what should be done....Please help me
as soon as possible......
Yahoo : mamun_ruetcse
By: Abdullah Al Mamun at 2011-08-11 23:20:37
Show Comment
Page 17
Your name (required):
Your email(required, will not be shown to the public):
Your sites URL (optional):
Your comments:
Type the two words:Type what you hear:Incorrect. Try again.
Add Your Comments
Page 18
More Tutorials by Issac
How to modify the objects using java classes
Java program for Cloning
Java program for changeable wrapper class
A tutorial on Chat Server and Chat Client in
VB.net
Chat Server in VB.net
Chat client in VB.net
How to open and read an XML file in VB.net
How to create an XML file in VB.net
XML and VB.net
How to create an XML file in VB.NET using
Dataset
Multi Threaded Client Socket Programming in
VB.net
Multi Threaded Server Socket Programming in
VB.net
More Tutorials in VB.net
Scope in VB.net
Unstructured Exception Handling in VB.net
Structured Exception Handling in VB.net
Creating Sub Procedures in VB.net
Creating Functions in VB.net
Passing a Variable Number of Arguments to
Procedures in VB.net
Specifying Optional Arguments with default
values in Procedures in VB.net
Preserving a Variable's Values between
Procedure Calls in VB.net
Procedure Delegates in VB.net
Properties in VB.net
Understanding Scope in VB.net
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Page 19
Multi threaded Socket Programming in VB.net
Client Socket Program sample in VB.net
Server Socket Program sample in VB.net
Getting an Exception's Number and
Description in VB.net
Raising an Exception Intentionally in VB.net
More Latest News
Most Viewed Articles (in VB.net )
Your first VB.NET Crystal Reports - A step by
step guide
For Loop in VB.net
How to export from DataGridView to excel
using VB.net
Send SMS using VB code
While Loop in VB.net
How to send email using VB.NET code
Using Select Case in VB.net
If…Else Statements in VB.net
Sub Procedures and Functions in VB.net
Most Emailed Articles (in VB.net)
Send SMS using VB code
For Loop in VB.net
If…Else Statements in VB.net
For Each…Next Loop in VB.net
The Option and Imports Statements in VB .NET
“Using If with And” and Comparing two
integers using If
The Select Case statement in VB.net
What's New in VB .NET? A comparison of VB
vs VB.net
While Loop in VB.net
Page 20
Arrays and Dynamic Arrays in VB.net
Client Socket Program sample in VB.net
How To Connect To A MySql Database in
VB.net
Insert cell data in an Excel file using OLEDB in
VB.net
A tutorial on Chat Server and Chat Client in
VB.net
Chat Server in VB.net
Do Loop in VB.net
Using Select Case in VB.net
Visual Basic Statements
What is .NET Framework and the Common
Language Runtime?
Arrays and Dynamic Arrays in VB.net
Operators in VB.net
• Test Papers • Android • AJAX • ASP.net • C • Cocoa • C++ • C# • Java • Javascript • JSF • JSP • J2ME • Java Beans • JDBC • Linux • Mac OS X • Perl • PHP • Python • Ruby • VB.net • Hibernate • Struts • Projects
Page 21
• Trends • Certification • Interview • Site Map • Contact Us • Forum
Related Links
Tutorial Archive: Trends Android AJAX ASP.net C Cocoa C++ C# Java Certification Interview Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X Perl PHP Python Ruby VB.net EJB Struts Hibernate
Latest Tutorials on: Trends Android AJAX ASP.net C Cocoa C++ C# Java Certification Interview Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X Perl PHP Python Ruby VB.net EJB Struts Hibernate
Get tutorials direct to your email:
Subscribe
© 2011 Java-samples.com
Tutorial Archive: Test Papers Trends Android AJAX ASP.net C Cocoa C++ C# Java Certification
Interview Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X Perl PHP Python Ruby VB.net
EJB Struts Hibernate
Latest Tutorials on: Trends Android AJAX ASP.net C Cocoa C++ C# Java Certification Interview
Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X Perl PHP Python Ruby VB.net EJB Struts
Hibernate
Bookmark & ShareXSelect from these web-based feed readers:AOL
Bloglines
Google Reader
My MSN
Netvibes
Newsisfree
Pageflakes
Yahoo
No matching services.
Page 22
.netShoutout100zakladok2 Tag2linkme7Live7.comA1-WebmarksA97abiAdftyAdifniAeroAll My FavesAmazonAmen Me!AOL
MailArmenixArtoAviary CaptureBaangBaiduBeboBentioBiggerPocketsBit.lyBizSugarBleetboxBlinklistBlipBloggerBloggyBlog
marksBlogtrottrBlurpaliciousBobrdobrBonzoBoxBookmarkingNetBookmarky.czBookmerkenBordomBox.netBrainifyBryderi.s
eBuddyMarksBuzzzyCamyooCardThisCare2ChiqCiripCiteULikeClassicalPlaceCndigColivia.deCommunicateConnoteacOOt
opiaCOSMiQCurate.usDeliciousDesignBumpDesignmooDigaCulturaDiggDiggitaDiglogDigoDigThisHostDigzignDiigoDipdive
DoMelhorDostiDotNetKicksDotShareDoubanDraugiem.lvDrimioDropjackDwelliciousDzoneEdelightEFactoreKudoselefanta.pl
EmailEmail
AppEmbarkonseuCliqueiEvernoteextraplayEzySpotFabDesignFabulously40FacebookFarkFarkindaFashiolistaFashion
BurnerFAVableFavesfavlogFavoritenFavoritesFavoritusFlakerFloss.proFolkdFormspringFreeDictionaryFresquiFriendFeedFr
iendsterfunPfwispGabbrGamekickerGiveALinkGlobalGrindGmailGo.vnGoduduGood NoowsGoogleGoogle
BuzzGoogle ReaderGraveeGreaterDebaterGrono.netHaber.gen.trHacker NewsHadash
HotHatenaHealthimizeHedgehogsHelloTxthistoriousHitmarksHot BookmarkHotklixHotmailHTML ValidatorHyvesideaREF!
Identi.caihavegotIndex4IndexorInformazioneInstapaperInvestorLinksiOrbixiSocietyiWiWJamespotJappy
TickerJoliPrintJumptagsKaboodleKaevurKaixin RepasteKetnooiKindle ItKipupKiRTSYKledyKommentingLa
tafaneraLaaikitLadenzeileLibrerioLifestreamLink NinjaLink-a-GogoLinkedInLinks
GutterLinkSharesLinkuj.czLiveJournalLockerBloggerLogger24Mail.ruMarkmeMashbordMawindomeinVZMekusharimMemoni
cMemori.ruMenéameMessengerMindbodygreenMister
WongMoemesto.ruMoikrugmototagzmRcNEtwORKMultiplymyAOLMyHayastanMylinkvaultMyspaceN4GNasza-
klasaNetLogNetvibesNetvouzNewsMeBackNewsTrustNewsvineNujijOdnoklassnikiOKNOtizieOneviewOnGoBeeOrkutOyyla
PackgPafnetPDF
OnlinePDFmyURLPhoneFavsPing.fmPlanypusPlaxoPlurkPochvalPopEditionPosteezyPosterousPrati.baPrintPrintFriendlyPu
shaQRF.inQuantcastQzoneRaiseYourVoiceRead It LaterRedditRediff
MyPageRedKumRideFixScoop.atScoop.itSekomanSelect2GetherShavehShe Told MeShirIntarInSimpySina WeiboSkyrock
BlogSlashdotSMISodaHeadSonicoSpeedtileSphinnSpinSnapSpoken To
YouSportpostSpreadlyspringpadSquidooStartaidStartlapStoryFollowerstudiVZStuffpitStumbleUponStumpediaStylehiveSvejo
SymbalooTaazaShareTagMarks.deTagvnTagzaTarpipeTellMyPoliticianThe Web
BlendThinkfinityThisNextThrowpileTip'dTopSitelerTransferrTranslateTuentiTulinqTumblrTusulTvinxTweetMemeTwitterTwitT
hisTypepadUpnews.itUrlaubswerkURLCaptViadeoVirbVisitezMonSiteVKontaktevKruguDruzeiVOX
SocialVybraliSMEVyoomWebnewsWebShareWhois LookupWindy CitizenWireFanWordPressWorioWykopXangaXINGY!
BookmarksY!
MailYammerYardbarkerYemleYiggYoolinkYorumcuyumYoublrYoubookmarksYouMobYuubyZakladok.netZanaticZicZacZing
MeZooLooZootool
DoneMessage sent! Share again.
Sending message...AddThis for Internet Explorer
Make sharing easier with AddThis for Internet Explorer.
Download
Don't show these
To: (email address)
From: (email address)Note: (optional)
255 character limit
More:
AddThisSettingsPrivacy Bookmark & ShareX
Make sharing easier with AddThis for Internet Explorer.
Page 23
Don't show these
FacebookTwitterEmailPrintRedditStumbleUponFavoritesGmailBloggerLinkedInTumblrMore... (335)
AddThisSettingsPrivacy