Results 1 to 3 of 3

Thread: [RESOLVED] Passing 'values' to generate reports

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    52

    Resolved [RESOLVED] Passing 'values' to generate reports

    Hi
    I'd like to generate reports based on values that the user is able to input. I need to generate reports during runtime. Tried most methods but not able to make it work.

    I'm using an MS access Database, VB .net 2002, Crystal reports for .NET

    below is the code that i've tried working with.

    What I get is a dialog box which requests for UserName and password which i dont want displayed. How could I avoid that?

    Please help.

    VB Code:
    1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    2.         OleCon.Close()
    3.         Dim ADOcon As New ADODB.Connection()
    4.  
    5.         ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_CRY_0016.mdb;Jet OLEDB:Database Password=prax;"
    6.         OleCon.ConnectionString = ADOcon.ConnectionString
    7.  
    8.         Dim repDA As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM testinfo WHERE testscore > 50", OleCon)
    9.         Dim MyCmdBuilderDT_rep As New System.Data.OleDb.OleDbCommandBuilder(repDA)
    10.  
    11.         repDA.Fill(repDS)
    12.         DataGrid1.DataSource = repDS.Tables(1)
    13.         MsgBox("pause")
    14.  
    15.         rptCrewRecord.Load("..\CrystalReport2.rpt")
    16.         rptCrewRecord.SetDataSource(repDS)
    17.  
    18.         Dim viewReport As New ReportView()
    19.         'Set the Parent Form of the Child window.
    20.  
    21.         'Display the new
    22.  
    23.         viewReport.ShowDialog()
    24.  
    25.  
    26.     End Sub
    Last edited by Hack; Mar 2nd, 2006 at 07:32 AM. Reason: Added [vbcode] [/vbcode] tags and for more clarity.

  2. #2

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    52

    Talking Re: Passing 'values' to generate reports

    Solved this one myself, but with a little help from looking at codes posted on this forum, and here I am posting the code in case it might be of some help to someone who comes by here.


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Dim Appl As New CRAXDDRT20.Application()
    Dim ADOcon As New ADODB.Connection()


    Dim App As New Scripting.FileSystemObject()
    Dim fso As New FileSystemObject()

    Dim Conn As Connection
    Dim strSQL As String
    Dim Rs As ADODB.Recordset

    Dim crewidSel As String = crewidX.SelectedValue

    Conn = New Connection()

    ADOcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\REPORTS_DB\TEST_CRY_0016.mdb;Jet OLEDB: Database Password=prax;"
    'OleCon.ConnectionString = ADOcon.ConnectionString


    ADOcon.Open()

    ' MsgBox("crewidx.sel is " & crewidSel)

    ' crewidSel is the variable that i get from the form and create a
    ' RecordSet and finally view the recordset using Crystal Report view.


    strSQL = "SELECT * FROM testinfo WHERE crewid = '" & crewidSel & "'"



    Rs = New ADODB.Recordset()
    Rs = ADOcon.Execute(strSQL)
    Appl = New CRAXDDRT20.Application()

    rptCrewRecord.Load("..\CrystalReport2.rpt")
    rptCrewRecord.SetDataSource(Rs)


    Dim viewReport As New ReportView()


    viewReport.ShowDialog()

    rptCrewRecord.Close()

    End Sub

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: [RESOLVED] Passing 'values' to generate reports

    Great!!!!!

    One thing, can you put vb code tags in your code so it will be more readable...
    Thanks.....

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width