Results 1 to 2 of 2

Thread: Crystal Report&vb.net Parameter passing to formula field in rpt file

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2003
    Location
    mumbai
    Posts
    36

    Crystal Report&vb.net Parameter passing to formula field in rpt file

    Hi everbody


    I am trying vb.net & Crystal for my further projects but i am not able to pass value to formula field in crystal report rpt file from my form which is calling the rpt


    Thanks & Regards

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Crystal Report&vb.net Parameter passing to formula field in rpt file

    Hi. Here a sample extracted from 101 VB.NET Samples.
    Code:
    Imports CrystalDecisions.CrystalReports.Engine
    Private Sub btnPreviewCustomerReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreviewCustomerReport.Click
            ' In this event the Customer Orders Report is loaded 
            ' and displayed in the crystal reports viewer.
            ' This report calls for a parameter which is pulled
            ' from the customer name combo box (cbCustomers).
    
            ' Objects used to set the parameters in the report
            Dim pvCollection As New CrystalDecisions.Shared.ParameterValues()
            Dim pdvCustomerName As New CrystalDecisions.Shared.ParameterDiscreteValue()
    
            ' Objects used to set the proper database connection information
            Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
            Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
    
            ' Create a report document instance to hold the report
            Dim rptCustomersOrders As New ReportDocument()
    
            Try
                ' Load the report
                rptCustomersOrders.Load("..\CustomerOrders.rpt")
    
                ' Set the connection information for all the tables used in the report
                ' Leave UserID and Password blank for trusted connection
                For Each tbCurrent In rptCustomersOrders.Database.Tables
                    tliCurrent = tbCurrent.LogOnInfo
                    With tliCurrent.ConnectionInfo
                        .ServerName = ServerName
                        .UserID = ""
                        .Password = ""
                        .DatabaseName = "Northwind"
                    End With
                    tbCurrent.ApplyLogOnInfo(tliCurrent)
                Next tbCurrent
    
                ' Set the discreet value to the customers name.
                pdvCustomerName.Value = cbCustomers.Text
    
                ' Add it to the parameter collection.
                pvCollection.Add(pdvCustomerName)
    
                ' Apply the current parameter values.
                rptCustomersOrders.DataDefinition.ParameterFields("@CustomerName").ApplyCurrentValues(pvCollection)
    
                ' Hide group tree for this report
                crvParameter.DisplayGroupTree = False
    
                ' Set the report source for the crystal reports viewer to the 
                ' report instance.
                crvParameter.ReportSource = rptCustomersOrders
    
                ' Zoom viewer to fit to the whole page so the user can see the report
                crvParameter.Zoom(2)
    
            Catch Exp As LoadSaveReportException
                MsgBox("Incorrect path for loading report.", _
                        MsgBoxStyle.Critical, "Load Report Error")
    
            Catch Exp As Exception
                MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
    
            End Try
        End Sub
    "The dark side clouds everything. Impossible to see the future is."

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