Please follow the Steps to Create Crystal Report in VB.NET,
Step 1: Create one vb.net project in visual studio.
Step 2: what we need to create simple crystal report ?
a.Dataset file (.xsd)
b.Crystal Report (.rpt)
c.One window form (.vb)
Step 3: Right click on project name in visual studio and click on add to add new items.
Step 4: Select Dataset from the list from Add New Item displayed box.
Name it as ReportDS as shown in Video.
Then you will be prompt with gray screen, it shows you have created dataset properly.
Drag Table from the Server explorer and drop it on dataset gray screen.
Step 5: Now its time to insert report file (.rtp), right click on project name in visual studio and click on add to add new items.
Step 6: Select CrystalReport from the list from Add new item displayed box.
Name it as Crystalreport1 as shown in video.
Then you will be prompt with the Crystal Reports Gallery,
Just click on "OK", then another page "Standard Report creation Wizard" will be prompted.
Then you need to select the database you created, in step 4.
For that click on ADO.NET Dataset and select you dataset from the list.as shown in video.
Then you will be prompted with table with fields, select the fields you require to show in report.
Then click on finish, and you have done.
Step 7: Now you need to add from to show this report in it. To do that, just add new form (.vb), and drag the Reportviewer form the data section in tool box.
Step 8: Take one button in that from, so that, when you click on that button, the report show appear.
Step 9: Then on click event of that button, paste this code below.
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PAMDB.mdb;User Id=admin;Password=;")
Dim cmd As OleDbCommand
cmd = New OleDbCommand("SELECT PAM_Medical_Information.tPatientName, PAM_Medical_Information.tDoctorCareProvider, PAM_Type_of_Medical_Entry.tMedicalTypeName, PAM_Medical_Information.tRx_OTC_MedsList_Dosage_Frequency, format(PAM_Medical_Information.dMedicalDate,'MM/dd/yyyy') as dMedicalDate , iif (PAM_Medical_Information.tPutOnMedicalInformationCard = '1', 'Yes', 'No') as tPutOnMedicalInformationCard FROM PAM_Medical_Information INNER JOIN PAM_Type_of_Medical_Entry ON PAM_Medical_Information.nMedicalTypeID = PAM_Type_of_Medical_Entry.iMedicalTypeID", conn) ' Change ID
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet() 'Set TypeDataset name That I have created before
If (ds IsNot Nothing And ds.Tables(0).Rows.Count > 0) Then
Dim cryRpt1 As New ReportDocument
Dim reportpath As String = Application.StartupPath & "\Reports\Medical.rpt"
CrystalReportViewer1.ReportSource = cryRpt1
Thats it, you have done finally, enjoy the report.
Hope this post will help you,
if yes please put comment below of this page,
Indianic Infotech Ltd (India)