Results 1 to 5 of 5

Thread: [RESOLVED] [2005] parameter in crystal report

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Resolved [RESOLVED] [2005] parameter in crystal report

    I enter a query in crystal report, and the query including parameter. How do I call this report in a form? (There are a textbox using to input parameter)

  2. #2
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Re: [2005] parameter in crystal report

    This should do it for you.
    VB Code:
    1. Private Sub frmEligReport_Load( _
    2.         ByVal sender As Object, _
    3.         ByVal e As System.EventArgs) Handles Me.Load
    4.  
    5.         Try
    6.             Dim NewReport As New ReportDocument
    7.             NewReport.Load("c:\MyCrystalReport.rpt")
    8.             ' dtEligStart and dtEligEnd are the parameters
    9.             ' from Crystal Reports.
    10.             ' StartDate & EndDate are just global varibles that
    11.             ' pull from datetime pickers on another form.
    12.             NewReport.SetParameterValue("dtEligStart", StartDate)
    13.             NewReport.SetParameterValue("dtEligEnd", EndDate)
    14.             NewReport.SetDatabaseLogon("User", "Pass", "Server", "Database")
    15.             CrystalReportViewer1.ReportSource = NewReport
    16.         Catch ex As Exception
    17.             MessageBox.Show( _
    18.                 ex.Message & vbNewLine & _
    19.                 ex.Source & vbNewLine & _
    20.                 ex.StackTrace, "Error", MessageBoxButtons.OK)
    21.         End Try
    22.     End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] parameter in crystal report

    Thx, Thats really good answer
    But I find that my parameter has some problem:
    Code:
    SELECT o.oDate, o.serialNo, o.dAddress, d.dName, d.dAddress, d.dNo  FROM `order` o, di_detail did, di_set di, dealer d where o.serialNo = {?serialNo}
    This is the command and supposed that {?serialNo} is equal to 1.
    Code:
    NewReport.SetParameterValue("serialNo", 1)
    Now I drop out the o.dAddress into crystal report for testing but it loops all of my o.dAddress..Does anyone know what's going on?

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2005] parameter in crystal report

    Use the Selection Expert to select records based on the parameter serialNo
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] parameter in crystal report

    The looping result is like this my attachment.
    Here is the selection expert, I can just using mysql statement in create new connetion..how do I select records based on the parameter to stop the looping?
    thx
    Attached Images Attached Images  
    Last edited by newpat; May 3rd, 2008 at 01:05 AM.

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