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.
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
Open Visual Studio .NET and select a new Visual
Basic .NET Project.
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.
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
Select OLE DB (
) from Create New Connection.
Select Microsoft OLE DB Provider for SQL
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
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.
Click Next Button
Select all fields from Product table to the right
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.
Now the designing part is over and the next step
is to call the created Crystal Reports in VB.NET through
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
Put the following source code in the button click
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
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.