Wrox Programmer Forums
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2004, 08:36 AM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sandeep
Default Passing logon info

hi!
    I am working with crystal reports in ASP.net and accessing a secured database through the report. My code goes as follows:

    Dim myConnection As New ConnectionInfo
    Dim myTableLogonInfo As New TableLogOnInfo
    Dim myTableLogonInfos As New TableLogOnInfos

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
           With myConnection
                .ServerName = "servername"
                .DatabaseName = "gardenworld"
                .UserID = "sa"
                .Password = "password"
            End With
            myTableLogonInfo.ConnectionInfo = myConnection
            myTableLogonInfo.TableName = "customers"
            myTableLogonInfos.Add(myTableLogonInfo)
            CrystalReportViewer1.LogOnInfo = myTableLogonInfos
            CrystalReportViewer1.ReportSource = New customer_rpt

    End Sub


Although i am passing database logon info through code it gives error "CrystalDecisions.CrystalReports.Engine.LogOnExcep tion: Logon failed". Am i missing something in code?


Thanks and Regards
Sandeep Saran
 
Old October 6th, 2004, 08:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is some sample code that passes multiple parameters values to 2 parameters.

**********************
'Add the following namespaces:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'CR Variables
Dim crReportDocument as New ReportDocument Dim crParameterFieldDefinitions as ParameterFieldDefinitions Dim crParameterFieldDefinition as ParameterFieldDefinition Dim crParameterValues as ParameterValues Dim crParameterDiscreteValue as ParameterDiscreteValue

'Create an instance of the strongly-typed report object crReportDocument = New CRParams() ' or load a report file:
crReportDocument.load("C:\test.rpt")

'Get the collection of parameters from the report crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields


' Set values for the first parameter:
'Access the specified parameter from the collection crParameterFieldDefinition = crParameterFieldDefinitions.Item("Country")

'Get the current values from the parameter field. At this point 'there are zero values set.
crParameterValues = crParameterFieldDefinition.CurrentValues


'Set the current values for the parameter field crParameterDiscreteValue = new ParameterDiscreteValue() crParameterDiscreteValue.Value = "Canada" '1st current value

'Add the first current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue)

'***** Only needed if the paramter has multiple values 'Since this parameter allows multiple values, the discrete value 'object needs to be reset. Destroy the previous instance and create 'a new instance.
crParameterDiscreteValue = nothing

crParameterDiscreteValue = new ParameterDiscreteValue() crParameterDiscreteValue.Value = "USA" '2nd current value

'Add the second current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue)
'*************


'All current parameter values must be applied for the parameter field.
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)

' Set values for the Second parameter:
crParameterFieldDefinition = crParameterFieldDefinitions.Item("Region")

crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterDiscreteValue = nothing
crParameterDiscreteValue = new ParameterDiscreteValue() crParameterDiscreteValue.Value = "CA" '1st current value
crParameterValues.Add(crParameterDiscreteValue)

'***** Only needed if the parameter has multiple values crParameterDiscreteValue = nothing crParameterDiscreteValue = new ParameterDiscreteValue() crParameterDiscreteValue.Value = "BC" '2nd current value
crParameterValues.Add(crParameterDiscreteValue)
'******

crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues)

'Set the viewer to the report object to be previewed.
crystalReportViewer1.ReportSource = crReportDocument
**********************



Renee C. Walker





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help passing login info to new page peterh Classic ASP Basics 4 January 10th, 2008 12:39 PM
Passing Database Logon Info happyslug BOOK: Professional Crystal Reports for VS.NET 1 February 14th, 2005 08:48 AM
Passing NT Login Info negrette Classic ASP Professional 1 October 25th, 2004 02:37 PM
Passing info between assemblies & projects BSkelding VB.NET 2002/2003 Basics 15 August 18th, 2004 08:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.