【问题标题】:an error of report document object model报表文档对象模型错误
【发布时间】:2011-04-28 04:32:46
【问题描述】:

我使用带有 vb.net 的 Visual Studio 2008 中的报表文档对象模型创建了一个报表。但是我发现了一个错误。当用户单击客户端的导出按钮时,将显示以下错误。但是在用户点击导出按钮之前第一次是OK的。

Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'zanhtet'. SQL State: 42000 Native Error:

这是调用报告代码。

        Dim ReportDocument As New ReportDocument()
        Dim ReportPath As String = Server.MapPath("~/ReportDocumentOM/DBlogInRDOM.rpt")

        ReportDocument.Load(ReportPath)
        ReportViewer.ReportSource = ReportDocument

        Dim ConnectionInfo As New ConnectionInfo

        ConnectionInfo.ServerName = "ZANHTET\SQLEXPRESS"
        ConnectionInfo.DatabaseName = "EAS_DevTrack4UDev"
        ConnectionInfo.UserID = "zanhtet"
        ConnectionInfo.Password = "123456"

        For Each Table As Table In ReportDocument.Database.Tables
            Dim TableLogOn As TableLogOnInfo = Table.LogOnInfo
            TableLogOn.ConnectionInfo = ConnectionInfo
            Table.ApplyLogOnInfo(TableLogOn)
        Next

我该如何解决这个问题。请帮帮我。

【问题讨论】:

  • 我假设您使用上面显示的凭据直接连接到数据库是否有效?

标签: asp.net vb.net crystal-reports reportdocument


【解决方案1】:

我不确定您上面的代码是在什么地方调用的。但是,如果您还没有这样做,那么请处理来自 reportviewer 的重要事件。在这些事件处理方法中,请确保再次调用此身份验证代码。

与导出相关的事件应该会给你带来好运,但你可能还需要处理其他几个事件(比如分页,我也有类似的问题)。

在此处查看报告查看器事件

http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.reportexport.aspx

【讨论】:

    猜你喜欢
    • 2011-08-28
    • 1970-01-01
    • 2012-05-10
    • 1970-01-01
    • 2011-01-13
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    相关资源
    最近更新 更多