Search code examples
c#crystal-reportscrystal-reports-2010

Crystal reports login prompt leaves database name blank when displaying report .net winform application


We have developed a CRM C#.NET application in VS2015 (.net 4.5) where we display alot of reports.

Since a couple of months we have a problem with a login prompt that is displaying when generating the report, all fields are correctly filled in except the database which is blank and also disabled.

enter image description here

This problem only occurs after we made database changes to a report (when adding tables ect.)

In the report we use SQL native client 11.

The database connection is passed in the code:

First the report is beeing loaded.

Next we set the login info:

var crConnectionInfo = new ConnectionInfo
{
    ServerName = servername,
    DatabaseName = databasename,
    UserID = userid,
    Password = password,
};


var crTables = _report.Database.Tables;
foreach (Table crTable in crTables)
{
    var crtableLogoninfo = crTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    crTable.ApplyLogOnInfo(crtableLogoninfo);                 
}


_report.SetDatabaseLogon(userid, password);
_report.DataSourceConnections[0].IntegratedSecurity = false;

After that we set the reportsource and the parameterfields:

 _crView.ReportSource = _report;    
 _crParameterFields = _crView.ParameterFieldInfo;

Has anyone else also encountered this issue?

Tried different solutions like adding legacyV2 runtime to the app.config.

 <startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
 </startup>

Solution

  • Solved the issue by changing the datatype in the report from SQLNCLI11 TO SQLOLEDB