Solved

How to use Crystal Reports in VB.NET

Posted on 2006-07-13
1
350 Views
Last Modified: 2010-04-23
Hi

I would like to create a report based on a database query using a windows form programmed with vb.net.

How can I do this using crystal reports in vs.net 2003?

I simply want to query the database and display it in crystal report format on the form.

Thanks

narmi
0
Comment
Question by:narmi2
1 Comment
 
LVL 2

Accepted Solution

by:
cwile earned 500 total points
ID: 17098927
I made all of the reports in crystal reports and saved them off onto a network share in their .rpt format making sure to NOT save data with report when I was complete.
You can hook up whatever database/query to the report at time of creation in crystal reports. Just be sure if you use DNS that the target machine has the same DNS.
I then wrote a small app in VB.net that opens a dialogue box, the user selects the report, it then opens the report using the crystal report viewer the user then puts in their selection criteria into the crystal report (or can you already have your query doing that). All you need to add to your form is the crystal report viewer

Here's the code my app uses:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim openDialog As New OpenFileDialog
        Me.Cursor = Cursors.WaitCursor
        openDialog.DefaultExt = "rpt"
        openDialog.Filter = "Report Files(*.RPT)|*.rpt|All Files(*.*)|*.*"

        Try
            If openDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                sReport = openDialog.FileName
                loadReport()
                Me.Cursor = Cursors.Default
            Else
                Me.Cursor = Cursors.Default
                End
            End If

            Me.Cursor = Cursors.Default
        Catch ex As Exception
            MsgBox(ex)
            Me.Cursor = Cursors.Default
            End
        End Try

    End Sub

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        cView.Height = Me.Height - 30
        cView.Width = Me.Width - 10
        cView.Left = 0
        cView.Top = 0
    End Sub


    Private Sub loadReport()

        Dim cRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
        cView.ReportSource = sReport
        cRpt.Load(sReport)
        cView.Show()

    End Sub
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question