0

我正在使用水晶报告制作报告网站,使用按钮查看报告。报告的第一页显示没有问题,但是当我单击导航按钮移动到报告的下一页时,我得到一个错误

“登录失败。详细信息:ADO 错误代码:0x 源:Microsoft SQL Native Client 描述:用户“sa”登录失败。SQL 状态:28000 本机错误:文件 C:\DOCUME~1\SOFTLITE\ASPNET\LOCALS~ 中的错误1\Temp\ClientReport {02A69EDD-9B03-4490-B3A2-5E5E5F5592D9}.rpt:无法连接:登录参数不正确。”

或水晶报表显示一个输入框登录数据库。我的代码是:

 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;
}

请帮我........

4

1 回答 1

1

我找到了解决方案

 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;
        }
  }
于 2013-03-29T07:56:20.727 回答