Results 1 to 3 of 3

Thread: [RESOLVED] Crystal reports - Pass parameters and change connection string

  1. #1

    Thread Starter
    Lively Member Shardox's Avatar
    Join Date
    Nov 2006
    Location
    Barcelona, Spain
    Posts
    123

    Resolved [RESOLVED] Crystal reports - Pass parameters and change connection string

    Hello guys,

    I have a report which datasource is a stored procedure in a SQL2005 database. I designed the report with a parameter value as an example to view results. Now I need to send the parameter programmatically and also I need to change the connection string for the report to connect with the database.

    Thanks!!
    Last edited by Shardox; Nov 23rd, 2006 at 05:56 AM. Reason: [RESOLVED]

  2. #2
    Lively Member
    Join Date
    Nov 2006
    Posts
    116

    Re: [2005] Crystal reports - Pass parameters and change connection string

    Hope this help:

    http://www.codeproject.com/useritems..._Connectio.asp

    VB Code:
    1. Dim rpt As New crpYourReport
    2.         rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape
    3.         Try
    4.             Dim rptViewer As New frmReport
    5.             rpt.SetDataSource(mydataset.Tables(TBL_NAME))
    6.             rptViewer.crpViewer.ReportSource = rpt
    7.  
    8.             Dim paramFields As New ParameterFields
    9.             Dim paramField As New ParameterField
    10.             Dim discreteVal As New ParameterDiscreteValue
    11.             paramField.ParameterFieldName = "paramname"
    12.             discreteVal.Value = modGeneral.strCompanyName
    13.             paramField.CurrentValues.Add(discreteVal)
    14.             paramFields.Add(paramField)
    15.  
    16.             rptViewer.crpViewer.ParameterFieldInfo = paramFields
    17.  
    18.             rptViewer.crpViewer.Zoom(7)
    19.             rptViewer.Show()
    20.         Catch Excep As Exception
    21.         End Try

  3. #3

    Thread Starter
    Lively Member Shardox's Avatar
    Join Date
    Nov 2006
    Location
    Barcelona, Spain
    Posts
    123

    Re: [2005] Crystal reports - Pass parameters and change connection string

    Thanks lingsn, your code worked!!

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