Solved

How to use Crystal Reports in VB.NET

Posted on 2006-07-13
1
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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