?
Solved

How to use Crystal Reports in VB.NET

Posted on 2006-07-13
1
Medium Priority
?
355 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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