Link to home
Start Free TrialLog in
Avatar of AaronNance
AaronNance

asked on

How do I pass database credentials to a Crystal Report in an ASP.NET webpage?

How can I pass database login information (username and password) to a crystal report, so that the user is NOT prompted for it?

Here is what I'm using...
        Dim strReportName As String = CStr(Request.QueryString("Report"))
        If strReportName = "" Then
            'There was a problem. Report Unknown
        Else
            Dim rptReport As New CrystalDecisions.Web.Report
            rptReport.FileName = "../Reports/" & strReportName
            CRViewer.Report = rptReport
        End If

When the User tries to view the report they are getting prompted for the ODBC password. I very much need to make this transparent to my Users. Please help.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AaronNance
AaronNance

ASKER

Thank you for the 591 page answer to my problem.


For those that don't want to weed through a helpful but rediculously long pdf...

Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine

Partial Class _1024_CRViewer
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim strReportName As String = CStr(Request.QueryString("Report"))

        If strReportName = "" Then
            'There was a problem. No Report Name.
            'Need to handle this error.
        Else
            Dim rptReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim strReportPath As String = Server.MapPath("../Reports/" & strReportName)
            ReportViewer.ReportSource = strReportPath
            ReportViewer.LogOnInfo(0).ConnectionInfo.ServerName = "YourServerName"
            ReportViewer.LogOnInfo(0).ConnectionInfo.DatabaseName = "YourDatabase"
            ReportViewer.LogOnInfo(0).ConnectionInfo.UserID = "YourUserName"
            ReportViewer.LogOnInfo(0).ConnectionInfo.Password = "YourPassword"
        End If

    End Sub

End Class
I agree the document is long.  However tere aren't many examples out there yet for the 2005 version of Crystal.

mlmcc