Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2004, 08:36 AM
Authorized User
 
Join Date: Jun 2003
Location: Indore, M.P., India.
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
Reply With Quote
  #2 (permalink)  
Old October 6th, 2004, 08:41 AM
Authorized User
 
Join Date: Jun 2003
Location: Northbrook, Illinois, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.