can.do
can.do

Reputation: 523

Crystal Reports DB Logon prompt although all table/report connections are made

Updating an older report system which was developed using VS 2008 and Crystal Reports. After updates, some reports started prompting for database login, while others work perfectly (with updates). Reports were changed to include new table and fields. All table and report document connections are established via common routine, similar to: SetDBLogon(myConnectionInfo, Me.CrystalReportViewer1.ReportSource)

Public Sub SetDBLogon(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
        Dim myTables As Tables = myReportDocument.Database.Tables
        For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
           Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
           myTableLogonInfo.ConnectionInfo = myConnectionInfo
           Try
               myTable.ApplyLogOnInfo(myTableLogonInfo)
           Catch ex As Exception
               MsgBox(ex.Message)
           End Try
        Next End Sub

It scans through each table sets the connection. Also scans sub-reports. Not sure what causes crystal reports to request login when it's already set specifically. When correct credentials are provided, it still fails to connect.

I've tried removing the report object and inserting the latest version.

Upvotes: 0

Views: 292

Answers (1)

can.do
can.do

Reputation: 523

Here's the issue and the solution to this problem (in my case).

Crystal Reports data sources can include, ADO .NET, OLE DB, ODBC, etc... with various drivers. The reports were created with a specific connection and driver, that no longer applied. I used a new database connection. Since the application scans each report and sets the correct connection parameters eventually, this would normally work, and it has worked in the past. But the problem was that the target system didn't have the right drivers for the connection provider I used. What made this harder to troubleshoot was that the connectivity piece in Crystal Reports is not very intuitive and duplicate connection names can be created with different providers -- same names different providers.

The solution was to open the report, go to : Database Expert > Set Datasource location

and this is the key part: Select the connection with the correct provider. In my case, this was SQLOLEDB

You can right-click the connection and choose "Properties" and check the provider. Set Datasource Location

Another way to resolve it would be to install the correct drivers and versions. In this case, since the SQLOLEDB provider was installed and already worked, I decided to keep all the reports exclusively use that provider instead.

You may need to check providers installed to verify, a direct way is to check registry, for example, SQL Native client SQLNCLI10 can be found:

HLKM\SOFTWARE\Microsoft\SQLNCLI10

Upvotes: 0

Related Questions