Results 1 to 2 of 2

Thread: Removing Log In Prompt of Crystal Report In Vb.Net 2005

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    12

    Removing Log In Prompt of Crystal Report In Vb.Net 2005

    I Was bit struggling with this Problem.......
    If u make a report in vb.net and display it using CrystalReport Viewer, then by default at runtime it prompts you for database password.
    I tried to google it. but found no proper solution.
    Finally a trick worked for me. so i thought of writing it down for all who are
    struggling with the same problem.

    Code:
    Dim report As ReportDoc = New ReportDoc
    
     Dim crParameterDiscreteValue As CrystalDecisions.Shared.ParameterDiscreteValue
    
            Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    
            Dim crParameterFieldLocation As ParameterFieldDefinition
    
            Dim crParameterValues As CrystalDecisions.Shared.ParameterValues
    
     crParameterFieldDefinitions = report.DataDefinition.ParameterFields
    
    
    
            '' Add a parameter value - START
    
            crParameterFieldLocation = crParameterFieldDefinitions.Item(0)
    
            crParameterValues = crParameterFieldLocation.CurrentValues
    
            crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    
            crParameterDiscreteValue.Value = Parameter1
    
            crParameterValues.Add(crParameterDiscreteValue)
    
            crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
    
            report.SetParameterValue(0, Parameter1)
    
           crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
    
           report.SetDatabaseLogon(DBUser, DBPass)       '***** DBUser  And DBPass are username and password of database
    
            rptviewer_1.ReportSource = report

    Here, SetDatabaseLogon does the trick...
    Hope It Helps to Someone...... !
    Cheers !
    -----------------------------------
    Kedar Kulkarni

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Removing Log In Prompt of Crystal Report In Vb.Net 2005

    Welcome to VBForums!

    Take a look at my post on this link.

    http://www.vbforums.com/showthread.p...hlight=crystal

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