title: Crystal Reports Failed Database Login
body: <p>After spending a good 3 to 4 hours on google trying to find any solution to my problem I haven't had much luck. </p>
  
  <p>Basically, we use crystal reports for our .NET applications with a sql server back end, we have many clients each with their own server and so our reports need to have their connections dynamically set. Up until a week ago this worked fine. However a few days ago a client reported they were getting a database login prompt for a report (only one report, the rest worked fine). We were quite stumped but we managed to reproduce it on a netbook which didn't have visual studio or sql server installed. In the end the dev decided to reproduce the report in the hope it was just an oddity in that particular report. </p>
  
  <p>Unfortunately a new client today also experienced the same problem, but this time for every crystal report they had - and also they worked on the netbook, so we are really quite lost here.</p>
  
  <p>Below is a screenshot of what our clients get presented with -</p>
  
  <p><a href="https://i.stack.imgur.com/HXjiY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HXjiY.png" alt="Screenshot"></a>
   </p>
  
  <p>and here is the code that I use to set the connection information in the report</p>
  
  <pre><code>                cI.ServerName = (string)builder["Data Source"];
                  cI.DatabaseName = (string)builder["Initial Catalog"];
                  cI.UserID = (string)builder["User ID"];
                  cI.Password = (string)builder["Password"];
  
                  foreach (IConnectionInfo info in cryRpt.DataSourceConnections)
                  {
                      info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                  }
  
                  foreach (ReportDocument sub in cryRpt.Subreports)
                  {
                      foreach (IConnectionInfo info in sub.DataSourceConnections)
                      {
                          info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                      }
                  }
  </code></pre>
  
  <p>As always, any help much appreciated.</p>