title: Crystal Report 2011 Login prompt in asp.net
body: <p>We are using Crystal Reports 2011 &amp; SQL Server 2008 (Windows 7 64 bit). Whenever I try to deploy the crystal reports in the IIS it is always prompting enter the database login information. I have tried the below options</p>
  
  <ol>
  <li>Set the login information in the code</li>
  <li>Set IIS app pool to LocalService</li>
  </ol>
  
  <p>Nothing works. Here is the code</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
              ConfigureCrystalReports();
          }
          else
          {
              ReportDocument doc = Session["Report"] as ReportDocument;
              SetLogon(doc);
              CrystalReportViewer1.ReportSource = doc;
              CrystalReportViewer1.RefreshReport();
          }
      }
  
      private void ConfigureCrystalReports()
      {
  
          ReportDocument reportDoc;
          if (!IsPostBack)
          {
              reportDoc = new ReportDocument();
              reportDoc.Load(Server.MapPath("~/Sample.rpt"));
              Session.Add("Report", reportDoc);
          }
          else
          {
              reportDoc = Session["Report"] as ReportDocument;
          }
  
          SetLogon(reportDoc);
  
          CrystalReportViewer1.ReportSource = reportDoc;
          CrystalReportViewer1.RefreshReport();
      }
  
      private void SetLogon(ReportDocument reportDoc)
      {
          var connectionInfo1 = new ConnectionInfo()
          {
              ServerName = @"ODBCDSN",
              DatabaseName = "hrdw_old",
              IntegratedSecurity = true
          };
  
          SetDBLogonForReport(connectionInfo1, reportDoc);
      }
  
      private void SetDBLogonForReport(ConnectionInfo connectionInfo1, ReportDocument reportDocument)
      {
          Tables tables = reportDocument.Database.Tables;
          foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
          {
              TableLogOnInfo tableLogonInfo = table.LogOnInfo;
  
              tableLogonInfo.ConnectionInfo = connectionInfo1;
              tableLogonInfo.ConnectionInfo.Type = ConnectionInfoType.SQL;
              table.ApplyLogOnInfo(tableLogonInfo);
  
  
          }
          reportDocument.SetDatabaseLogon(connectionInfo1.UserID, connectionInfo1.Password);
      }
  }
  </code></pre>
  
  <p>Steps tried in IIS:
  Application pool: ASP.NET 4.0 Default app pool
  Also enabled Windows Authentication in IIS &amp; disabled anonymous authentication.
  Tried anonymous authentication only.
  SQL Server has both windows and sql server authentication.</p>
  
  <p>I will not be able to use dataset since the crystal reports will be developed by someone using command objects. It works perfectly good in the Visual studio 2010 environment. But doesnt work in IIS.</p>
  
  <p>Am I missing something basic? Any help is appreciated.</p>
  
  <p>Thanks</p>
  
  <p>Shankar.</p>