How to set the Provider for CrystalDecisions.Enterprise.Desktop.Report?

272 Views Asked by At

For our reporting environment, we allow users to run reports "online" (the code for this is based on CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument) or "offline" which is to schedule them on the Business Objects server directly. This code is based on CrystalDecisions.Enterprise.Desktop.Report.

For the online report, we're able to programmatically set the provider with this code:

If crTableNew.ConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE Then
    crLogonInfo = CType(crAttributes("QE_LogonProperties"), PropertyBag)
    crLogonInfo("Data Source") = serverName
    crLogonInfo("Initial Catalog") = databaseName
    crLogonInfo("Provider") = "SQLNCLI11"
End If

However, the equivalent code for offline doesn't seem to expose the "Provider" property. The equivalent object is roughly this:

CrystalDecisions.Enterprise.Desktop.Report.ReportLogons.Item(tableIndex) but none of the properties there seem to be the Provider.

Anyone able to help?

1

There are 1 best solutions below

1
On

The closest corresponding ReportLogon property to the LoginInfo Provider property is the ServerType property. However, I don't think you need this in order to set the database credentials.

You can probably do something like this

    foreach(ReportLogon reportLogon in reportLogons)
    {
       reportLogon.UseOriginalDataSource = false;

       reportLogon.CustomServerName = serverName;
       reportLogon.CustomUserName = userId;
       reportLogon.CustomPassword = password;
       reportLogon.CustomDatabaseName = databaseName;

       foreach(TablePrefix tablePrefix in reportLogon.TableLocationPrefixes)
       {
          tablePrefix.MappedTablePrefix = databaseName + ".dbo.";
          tablePrefix.UseMappedTablePrefix = true;
       }
    }

Looping through the TableLocationPrefixes ensures that all referenced tables or sprocs are associated to the database specified in the logon credentials.