cancel
Showing results for 
Search instead for 
Did you mean: 

CR asking for logon creds when they are set programmatically

Former Member
0 Kudos

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.Load(reportPath)

                    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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

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.

        InitializeComponent()

        '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

            crTable.ApplyLogOnInfo(crTableLogOnInfo)

        Next

        '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

Former Member
0 Kudos

Thanks Ludek.  I will keep this in mind in the future.  I ended resolving my issue by change the Provider for my datasoure from "SQLNC11" to "SQLOLEDB".  That resolved my issue.  However, I will look into changing our code to be similiar to what you suggested.  I think it will prevent further headaches in the future.  We do not have a great separate dev environment.  So we are oftend copying reports around and changing the datasource for dev / testing  purposes and then changing back to production.  If I am reading your response correct, this activity will cause issues using "SetDatabaseLogon" and that using ApplyLogOnIfno will be the best method.  Am I understanding you correctly?

thanks

doug

former_member183750
Active Contributor
0 Kudos

Yes that is correct. For more details see the SAP Crystal Reports .NET SDK Developer Guide

Just search for setdatabaselogon.

You will see that it says the following:

- Ludek

0 Kudos

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.

Don

Answers (0)