简体   繁体   中英

Crystal report Error when navigating to next page?

I am making a reporting website using crystal report,using a button to view the report. The first page of the report is displayed without a problem but when I click the navigation buttons to move to the next page of the report, I either get an error

"Logon failed. Details: ADO Error Code: 0x Source: Microsoft SQL Native Client Description: Login failed for user 'sa'. SQL State: 28000 Native Error: Error in File C:\\DOCUME~1\\SOFTLITE\\ASPNET\\LOCALS~1\\Temp\\ClientReport {02A69EDD-9B03-4490-B3A2-5E5E5F5592D9}.rpt: Unable to connect: incorrect log on parameters."

or Crystal Reports shows an input box to log on in database. My code is:

 protected void Button1_Click(object sender, EventArgs e)
{
            ReportDocument Summaryrpt = new ReportDocument();
            Summaryrpt.Load(Server.MapPath("BookSummary.rpt"));
            Summaryrpt.SetDatabaseLogon("sa", "nirvana", "Compro4", "lottery");
            CrystalReportViewer1.ReportSource = Summaryrpt;
}

please help me........

I found the solution

 protected void Button1_Click(object sender, EventArgs e)
 {
        ReportDocument Summaryrpt = new ReportDocument();
        Summaryrpt.Load(Server.MapPath("BookSummary.rpt"));
        CrystalReportViewer1.ReportSource = Summaryrpt;
        var connectionInfo = new ConnectionInfo();
        connectionInfo.ServerName = "ComproLottery.db.6456862.hostedresource.com";
        connectionInfo.DatabaseName = "ComproLottery";
        connectionInfo.Password = "Br0@dW@ys68";
        connectionInfo.UserID = "ComproLottery";
        connectionInfo.Type = ConnectionInfoType.SQL;
        for (int i = 0; i < CrystalReportViewer1.LogOnInfo.Count; i++)
        {
            CrystalReportViewer1.LogOnInfo[i].ConnectionInfo = connectionInfo;
        }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM