Skip to Content
author's profile photo Former Member
Former Member

CR asking for logon creds when they are set programmatically

Ok. So I know this question has been asked alot, but I am having this issue now and have had it in the past. I would like to try and understand what is going on and come up with a permanent solution so this does not keep happening.

I have a .Net web application with CR embedded into the solution. When I run the report in production it is asking me for the database information. I am supplying the db, password, etc using code like the one seen below;

reportDatabase = "xxxx"

reportServer = "xxxx"

reportUsername = "xxx"

reportUserpwd = "xxx"

reportPath = Server.MapPath("Reports/Traceability/TraceForward/TraceForwardGiveUBIGetCustomer.rpt")


newTraceabilitycr.ReportDocument.SetDatabaseLogon(reportUsername, reportUserpwd, reportServer, reportDatabase)

newTraceabilitycr.ReportDocument.SetParameterValue("@UBI", parmUbi)

Again it is working fine in my dev environment. Also not all reports have this issue in production, only some of them. Any ideas? Please help.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Nov 12, 2015 at 06:43 PM

    SetDatabaseLogon will work if the report is still going against the same datasource, etc., it was originally created off of. If anything changes (server, UID, etc.) you want to use applylogoninfo. Something like this:

           'This call is required by the Windows Form Designer.
            'Add any initialization after the InitializeComponent() call
            'Create an instance of the strongly-typed report object
            crReportDocument = New CrystalReport1()
            'Setup the connection information structure to be used
            'to log onto the datasource for the report.
            crConnectionInfo = New ConnectionInfo()
            With crConnectionInfo
                .ServerName = "escalade"    'physical server name
                .DatabaseName = "Pubs"
                .UserID = "sa"
                .Password = "admin"
            End With
            'Get the table information from the report
            crDatabase = crReportDocument.Database
            crTables = crDatabase.Tables
            'Loop through all tables in the report and apply the connection
            'information for each table.
            For Each crTable In crTables
                crTableLogOnInfo = crTable.LogOnInfo
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo
            'Set the viewer to the report object to be previewed.
            CrystalReportViewer1.ReportSource = crReportDocument

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow me on Twitter

    Got Enhancement ideas? Use the SAP Idea Place

    Add a comment
    10|10000 characters needed characters exceeded

    • Also, you said you fixed it by changing the DB driver from the new client dll to the old MDAC driver.

      This suggests you have not updated the report to use the client 11 dll.

      Will work but MS doesn't fully support the MDAC drivers in Newer versions of SQL DB.

      FYI, You may want to update your reports to ODBC, MS is dropping their OLE DB driver and only going to support ODBC.


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.