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
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