0

我正在尝试将水晶报告文档导出为 PDF,并且收到此错误消息。我可以连接到数据库并查询数据,将其放入数据集并将数据集绑定到报告对象。但是当我导出到 HttpResponse 时出现以下错误。有人遇到过这个问题吗?请帮忙。谢谢。

Logon failed.
Details: ADO Error Code: 0x
Source: Microsoft OLE DB Provider for SQL Server
Description: Login failed for user '727_User'.
SQL State: 42000
Native Error: Error in File C:\Windows\TEMP\ABCDReport {9242A97D-A37F-4B18-A22E-8F0F22416D73}.rpt:
Unable to connect: incorrect log on parameters.

这是我背后的 C# 代码。

rep.SetDataSource(ds.Tables[0]);  
rep.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ABCDReport");
4

1 回答 1

1

我发现了问题。我忘记将第二个数据表绑定到子报表,这导致了问题。以下是我的最终代码。谢谢。

rep.SetDataSource(ds.Tables[0]);
        if (ds.Tables.Count > 1)
        {
            if (ds.Tables[1].Rows.Count > 0)
            {
                rep.OpenSubreport("Subrep1").SetDataSource(ds.Tables[1]);
            }

        }



rep.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ABCDReport");
于 2013-01-21T07:56:26.013 回答