Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. crystal report

crystal report

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabasewpf
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eatwork
    wrote on last edited by
    #1

    Hi everyone, Not sure if this is the right place for crystal report posts but here I go. I have a windows application that has been coded in vb.net, in VS2003. the database is MS Access based. I am working on a quotation system and have completed the forms that the user will utilize for input. The windows apps created are not bound to the database and store a local dataset that holds all of the information/tables/data that the user has came in contact with. I would like to create reports that will be populated based on the local dataset. I was wondering if there is any way to create a crystal report, to be used as the template, without binding the report to the database, and then passing the local dataset data into the report that needs to be printed. I have read online about a push method, but they say that can be really slow in creating a report with lots of tables and data, and all of the other solutions are for vs2005. Thank you for reading this post, I am new to crystal reports and am looking for any tutorials etc that might help with this problem. Thank you.

    eatwork

    D 1 Reply Last reply
    0
    • E eatwork

      Hi everyone, Not sure if this is the right place for crystal report posts but here I go. I have a windows application that has been coded in vb.net, in VS2003. the database is MS Access based. I am working on a quotation system and have completed the forms that the user will utilize for input. The windows apps created are not bound to the database and store a local dataset that holds all of the information/tables/data that the user has came in contact with. I would like to create reports that will be populated based on the local dataset. I was wondering if there is any way to create a crystal report, to be used as the template, without binding the report to the database, and then passing the local dataset data into the report that needs to be printed. I have read online about a push method, but they say that can be really slow in creating a report with lots of tables and data, and all of the other solutions are for vs2005. Thank you for reading this post, I am new to crystal reports and am looking for any tutorials etc that might help with this problem. Thank you.

      eatwork

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      eatwork wrote:

      working on a quotation system

      eatwork wrote:

      not bound to the database

      Just a question - don't you think it would be nice (from a customer services point of view) to keep track of quotes and use them as follow-ups? e.g. If the quote was not accepted, why not? Your app, just a suggestion.

      eatwork wrote:

      create a crystal report, to be used as the template, without binding the report to the database, and then passing the local dataset data into the report that needs to be printed.

      Sure there is & it's real simple. Build your template report first and pass the dataset to the method that calls the report, e.g.

      'declare pre-built report
      Public myReport1 = New myCrystalReport

      Public Sub BuildMyReport(ByVal ds As DataSet)

      myReport1.SetDataSource(ds)
      myForm.myReportViewer.ReportSource = myReport1

      End Sub

      Is that what you're after?

      E 1 Reply Last reply
      0
      • D Dave Sexton

        eatwork wrote:

        working on a quotation system

        eatwork wrote:

        not bound to the database

        Just a question - don't you think it would be nice (from a customer services point of view) to keep track of quotes and use them as follow-ups? e.g. If the quote was not accepted, why not? Your app, just a suggestion.

        eatwork wrote:

        create a crystal report, to be used as the template, without binding the report to the database, and then passing the local dataset data into the report that needs to be printed.

        Sure there is & it's real simple. Build your template report first and pass the dataset to the method that calls the report, e.g.

        'declare pre-built report
        Public myReport1 = New myCrystalReport

        Public Sub BuildMyReport(ByVal ds As DataSet)

        myReport1.SetDataSource(ds)
        myForm.myReportViewer.ReportSource = myReport1

        End Sub

        Is that what you're after?

        E Offline
        E Offline
        eatwork
        wrote on last edited by
        #3

        Thank you for your reply and insight. I currently do store the quotes in a database but do not store the reasons why they might/might not have been accepted. But I will ask the users if that is something they would like in the system. I tried the code you suggested, but it doesn't seem to be working for me. The form opens, but without a report in the report viewer. This code is in the pop up form after the user clicks on a button and I call the forms showdialog method my code: Private Sub Form_Load() myReport1.SetDataSource(Me.p_dataset) Me.CrystalReportViewer1.ReportSource = myReport1 End sub also tried Private Sub Form_Load() myReport1.SetDataSource(Me.p_dataset) Me.CrystalReportViewer1.ReportSource = myReport1.FilePath.ToString End sub Do you know of any place on the internet that might give me a tutorial to create a "template report"? All of the reports I have seen online are databinded to a database or have a database/xsd file that it reads data in from. I can't really use those examples because my dataset is created at runtime. I am fairly new to .net and coding, and have never done a crystal report through the integrated crystal reports in vs2003. Thank you very much

        eatwork

        D 1 Reply Last reply
        0
        • E eatwork

          Thank you for your reply and insight. I currently do store the quotes in a database but do not store the reasons why they might/might not have been accepted. But I will ask the users if that is something they would like in the system. I tried the code you suggested, but it doesn't seem to be working for me. The form opens, but without a report in the report viewer. This code is in the pop up form after the user clicks on a button and I call the forms showdialog method my code: Private Sub Form_Load() myReport1.SetDataSource(Me.p_dataset) Me.CrystalReportViewer1.ReportSource = myReport1 End sub also tried Private Sub Form_Load() myReport1.SetDataSource(Me.p_dataset) Me.CrystalReportViewer1.ReportSource = myReport1.FilePath.ToString End sub Do you know of any place on the internet that might give me a tutorial to create a "template report"? All of the reports I have seen online are databinded to a database or have a database/xsd file that it reads data in from. I can't really use those examples because my dataset is created at runtime. I am fairly new to .net and coding, and have never done a crystal report through the integrated crystal reports in vs2003. Thank you very much

          eatwork

          D Offline
          D Offline
          Dave Sexton
          wrote on last edited by
          #4

          Ok, I did up a small sample app to demonstrate how to get this right. Here's how I did it. I started off by creating a form with 3 textboxes to input data to the dataset (I chose "Name", "Product" & "Quantity" as fields for the dataset), and 2 buttons for "Add to dataset" & "View report". I created the dataset (called dsQuote) and declared it at modular level in Form1 (Friend ds1 As New dsQuote) I created a second form and added a Crystal Report Viewer to it (called "crv") I added a new Crystal Report to the solution and used the Report Expert wizard to select the dataset i created earlier. I set the solution start up object to call Sub Main(). Then I just tied it all together with a bit of code - have a look at the code below. SubMain

          Module modMain

          Public WithEvents frm1 As Form1
          Public WithEvents frmR As frmReport
          
          Sub Main()
              frm1 = New Form1
              Application.Run(frm1)
          End Sub
          

          End Module

          Code on Form1

          Friend ds1 As New dsQuote

          Private Sub btnAdd\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
          
              Dim dr As DataRow = ds1.tblQuote.NewRow
          
              'add info to dataset
              dr.Item("name") = txtName.Text
              dr.Item("product") = txtProduct.Text
              dr.Item("quantity") = txtQuantity.Text
          
              ds1.tblQuote.Rows.Add(dr)
          
              'clear the textboxes
              txtQuantity.Clear()
              txtProduct.Clear()
              With txtName
                  .Clear()
                  .Focus()
              End With
          
          End Sub
          
          Private Sub btnReport\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
              frmR = New frmReport
              frmR.Show()
          End Sub
          

          Code on Form2

          Public rptQ As Quote

          Private Sub frmReport\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
          
              rptQ = New Quote
              rptQ.SetDataSource(frm1.ds1)
              Me.crv.ReportSource = rptQ
          
          End Sub
          

          That should solve it for you. :) EDIT: Sorry for the crappy naming conventions, I was in a bit of a hurry. :) -- modified at 3:59 Friday 18th August, 2006

          E 2 Replies Last reply
          0
          • D Dave Sexton

            Ok, I did up a small sample app to demonstrate how to get this right. Here's how I did it. I started off by creating a form with 3 textboxes to input data to the dataset (I chose "Name", "Product" & "Quantity" as fields for the dataset), and 2 buttons for "Add to dataset" & "View report". I created the dataset (called dsQuote) and declared it at modular level in Form1 (Friend ds1 As New dsQuote) I created a second form and added a Crystal Report Viewer to it (called "crv") I added a new Crystal Report to the solution and used the Report Expert wizard to select the dataset i created earlier. I set the solution start up object to call Sub Main(). Then I just tied it all together with a bit of code - have a look at the code below. SubMain

            Module modMain

            Public WithEvents frm1 As Form1
            Public WithEvents frmR As frmReport
            
            Sub Main()
                frm1 = New Form1
                Application.Run(frm1)
            End Sub
            

            End Module

            Code on Form1

            Friend ds1 As New dsQuote

            Private Sub btnAdd\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
            
                Dim dr As DataRow = ds1.tblQuote.NewRow
            
                'add info to dataset
                dr.Item("name") = txtName.Text
                dr.Item("product") = txtProduct.Text
                dr.Item("quantity") = txtQuantity.Text
            
                ds1.tblQuote.Rows.Add(dr)
            
                'clear the textboxes
                txtQuantity.Clear()
                txtProduct.Clear()
                With txtName
                    .Clear()
                    .Focus()
                End With
            
            End Sub
            
            Private Sub btnReport\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
                frmR = New frmReport
                frmR.Show()
            End Sub
            

            Code on Form2

            Public rptQ As Quote

            Private Sub frmReport\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            
                rptQ = New Quote
                rptQ.SetDataSource(frm1.ds1)
                Me.crv.ReportSource = rptQ
            
            End Sub
            

            That should solve it for you. :) EDIT: Sorry for the crappy naming conventions, I was in a bit of a hurry. :) -- modified at 3:59 Friday 18th August, 2006

            E Offline
            E Offline
            eatwork
            wrote on last edited by
            #5

            Hi kulazfuk, Awesome sample, it works! Not quite what I was expecting, and I guess I need to create a blank xsd for it..but it works and thats all that matters. Thanks a lot for your help

            eatwork

            1 Reply Last reply
            0
            • D Dave Sexton

              Ok, I did up a small sample app to demonstrate how to get this right. Here's how I did it. I started off by creating a form with 3 textboxes to input data to the dataset (I chose "Name", "Product" & "Quantity" as fields for the dataset), and 2 buttons for "Add to dataset" & "View report". I created the dataset (called dsQuote) and declared it at modular level in Form1 (Friend ds1 As New dsQuote) I created a second form and added a Crystal Report Viewer to it (called "crv") I added a new Crystal Report to the solution and used the Report Expert wizard to select the dataset i created earlier. I set the solution start up object to call Sub Main(). Then I just tied it all together with a bit of code - have a look at the code below. SubMain

              Module modMain

              Public WithEvents frm1 As Form1
              Public WithEvents frmR As frmReport
              
              Sub Main()
                  frm1 = New Form1
                  Application.Run(frm1)
              End Sub
              

              End Module

              Code on Form1

              Friend ds1 As New dsQuote

              Private Sub btnAdd\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
              
                  Dim dr As DataRow = ds1.tblQuote.NewRow
              
                  'add info to dataset
                  dr.Item("name") = txtName.Text
                  dr.Item("product") = txtProduct.Text
                  dr.Item("quantity") = txtQuantity.Text
              
                  ds1.tblQuote.Rows.Add(dr)
              
                  'clear the textboxes
                  txtQuantity.Clear()
                  txtProduct.Clear()
                  With txtName
                      .Clear()
                      .Focus()
                  End With
              
              End Sub
              
              Private Sub btnReport\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
                  frmR = New frmReport
                  frmR.Show()
              End Sub
              

              Code on Form2

              Public rptQ As Quote

              Private Sub frmReport\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
              
                  rptQ = New Quote
                  rptQ.SetDataSource(frm1.ds1)
                  Me.crv.ReportSource = rptQ
              
              End Sub
              

              That should solve it for you. :) EDIT: Sorry for the crappy naming conventions, I was in a bit of a hurry. :) -- modified at 3:59 Friday 18th August, 2006

              E Offline
              E Offline
              eatwork
              wrote on last edited by
              #6

              sorry, ignore the last post, starting to confuse myself. Thanks again

              eatwork

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups