Click here to Skip to main content
11,718,016 members (84,632 online)
Click here to Skip to main content
Add your own
alternative version

Step by Step Creation of Crystal Report using its Features Group, Graph, Cross-Tab and Sub Report

, 20 Jan 2011 CPOL 900.6K 18.6K 200
This article will help beginners to work with Crystal reports features easily.
CrystalReport.zip
CrystalReport
App_Code
dsTestCrystal.xss
App_Data
CrossTab.rpt
CrystalReport.rpt
CrystalReport2.rpt
database.xss
Graph.rpt
GroupCrystal.rpt
SimpleCrystal.rpt
SubReport.rpt
vwd.webinfo
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine

Partial Class TestCrystal
    Inherits System.Web.UI.Page

    Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShow.Click
        Dim rptDoc As New ReportDocument
        Dim ds As New dsTestCrystal
        'Dim sqlCon As SqlConnection
        Dim dt As New DataTable

        'dt.TableName = "Crystal Report Example"
        'sqlCon = New SqlConnection("server='servername';Initial Catalog='databasename';user id='userid';password='password'")
        'Dim da As New SqlDataAdapter("select Stud_Name, Class, Subject, Marks from stud_details", sqlCon)

        'da.Fill(dt)

        'dt.WriteXmlSchema(Server.MapPath("database.xsd"))
        'dt.WriteXml(Server.MapPath("database.xml"))

        dt.ReadXmlSchema(Server.MapPath("database.xsd"))
        dt.ReadXml(Server.MapPath("database.xml"))

        If DropDownList1.SelectedValue = 0 Then
            ds.Tables(0).Merge(dt)
            rptDoc.Load(Server.MapPath("SimpleCrystal.rpt"))
            rptDoc.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rptDoc

        ElseIf DropDownList1.SelectedValue = 1 Then
            ds.Tables(0).Merge(dt)
            rptDoc.Load(Server.MapPath("GroupCrystal.rpt"))
            rptDoc.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rptDoc

        ElseIf DropDownList1.SelectedValue = 2 Then
            ds.Tables(0).Merge(dt)
            rptDoc.Load(Server.MapPath("Graph.rpt"))
            rptDoc.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rptDoc

        ElseIf DropDownList1.SelectedValue = 3 Then
            ds.Tables(0).Merge(dt)
            rptDoc.Load(Server.MapPath("CrossTab.rpt"))
            rptDoc.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rptDoc

        ElseIf DropDownList1.SelectedValue = 4 Then
            ds.Tables(0).Merge(dt)
            rptDoc.Load(Server.MapPath("SubReport.rpt"))
            rptDoc.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rptDoc

        End If
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Toniyo Jackson
Software Developer
India India
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150901.1 | Last Updated 20 Jan 2011
Article Copyright 2011 by Toniyo Jackson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid