Results 1 to 5 of 5

Thread: Range Parameters?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    40

    Range Parameters?

    I am currently working with a report that displays four columns and the report source is a store procedure that takes two parameters or arguments from the user in order to display the data. This is going to be developed in visual studio 2005m language: visual.

    My question is, How can I pass parameters from one webform to another webform and display the data in the second one? Obviously the second webform has the crystal report viewer but I dont know how to send this two parameters which are date range to display the data that the user wants.

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Range Parameters?

    Well, when you submit the first webform, read the values from the input boxes and put them the into session variables. Then when you show your second form, read the values from the session variables, and pass them as parameters in your Crystal Reports.

    The Crystal Report has to read the data from a Procedure (that's the way I know at least), and when you pass the values as parameters, Crystal Report will pass the same values to the Procedure.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    40

    Re: Range Parameters?

    The Crystal Report has to read the data from a Procedure (that's the way I know at least), and when you pass the values as parameters, Crystal Report will pass the same values to the Procedure.

    How Can I do this?????

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Range Parameters?

    Well, I know it's not possible to make a procedure in Access database, so if you are using Access as your database, then I don't know how to do this... (then wait for someone else who knows more about this to reply to your question)

    But... if you are using SQL Server (the only one I know...), You can make a procedure like this:
    Code:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE proc_ListRecords
    	@FromDate datetime,
    	@ToDate datetime
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    	SELECT * FROM SOME_TABLE WHERE SOME_TABLE.FromDate BETWEEN @FromDate AND @ToDate
    END
    GO
    Then in your Crystal Reports, you have to select the procedure "proc_ListRecords" to read the data from, and Crystal Reports will add the FromDate, and ToDate parameters automatically.

    After that, in code, you have to pass the values to the Crystal Report when you run it, something like this:
    Please note that this is VB6 code, I'm not sure how you do this in .NET, but it should be simmilar...
    Code:
        Dim CRApp As New CRAXDDRT.Application
        Dim PrintReport As CRAXDDRT.Report
        Dim ReportFileName As String
    
            ReportFileName = App.Path & "\Reports\CR_Report.rpt"
            Set PrintReport = CRApp.OpenReport(ReportFileName)
            
            PrintReport.Database.Tables(1).ConnectionProperties.Item("user id") = ConnUserName
            PrintReport.Database.Tables(1).ConnectionProperties.Item("password") = ConnPassword
    
            PrintReport.ParameterFields.GetItemByName("@FromDate").AddCurrentValue FromDate
            PrintReport.ParameterFields.GetItemByName("@ToDate").AddCurrentValue ToDate
    
            PrintReport.SelectPrinter "", "printer name here, or comment line to select default printer", ""
            PrintReport.PrintOut False
            
            Do While PrintReport.PrintingStatus.Progress = crPrintingInProgress
                DoEvents
            Loop
    Sorry if I could not be of more help (I don't know .NET very well), I did some webforms in the past, but did not need to do any Crystal Reports in it. I only did Crystal Reports in VB6...
    Last edited by CVMichael; Jun 14th, 2007 at 08:54 AM.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    40

    Re: Range Parameters?

    Muchas Gracias!!! = Thank You!!!

    I will try to change it to vb.net and see if it works

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