Asp.net 带有对象数据集的Crystal报表

Asp.net 带有对象数据集的Crystal报表,asp.net,.net,vb.net,crystal-reports,Asp.net,.net,Vb.net,Crystal Reports,我的任务是重写一些水晶报告。我大约在1999年找到了原始报告,在VS 2008中打开了它们,进行了更改并保存了它们 现在,它们引用了一个不再存在的数据库。因此,我删除了这个数据源并添加了一个.NET对象数据源。我改变了周围的一切,以便字段现在可以看到这个新的数据源 我的目的是创建报告,并在运行时向其传递一个数据表。此表是通过运行已创建的存储过程创建的 当我运行它时,我会看到报告的第一页。但是,当我尝试更改页面或打印时,会出现一个错误: 登录失败。详细信息:crdb_adoplus:对象引用未设置

我的任务是重写一些水晶报告。我大约在1999年找到了原始报告,在VS 2008中打开了它们,进行了更改并保存了它们

现在,它们引用了一个不再存在的数据库。因此,我删除了这个数据源并添加了一个.NET对象数据源。我改变了周围的一切,以便字段现在可以看到这个新的数据源

我的目的是创建报告,并在运行时向其传递一个数据表。此表是通过运行已创建的存储过程创建的

当我运行它时,我会看到报告的第一页。但是,当我尝试更改页面或打印时,会出现一个错误:

登录失败。详细信息:crdb_adoplus:对象引用未设置为对象的实例。文件C中出错:…\MR01{8E5164A9-4B01-4019-81E6-87AED65A02DF}。rpt:无法连接:登录参数不正确

这是我的密码:

<CR:CrystalReportViewer ID="theCrystalReportViewer" visible="false" runat="server" EnableDatabaseLogonPrompt="false"   />


        Dim theDataTable As DataTable = tbl
        theDataTable.TableName = "tableName"
        Dim oReport As New ReportDocument

        Dim sRptPath As String = "...Reports\MR01.rpt"
        oReport.Load(sRptPath)
        oReport.SetDataSource(theDataTable)
        'oReport.SetDatabaseLogon("####", "####", "####", "#####")


        Dim c As ConnectionInfo = New ConnectionInfo()
        c.ServerName = "####"
        c.DatabaseName = "####"
        c.Password = "####"
        c.UserID = "####"
        c.Type = ConnectionInfoType.SQL
        c.IntegratedSecurity = False

        For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1
            theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c
        Next


        'theCrystalReportViewer.EnableDatabaseLogonPrompt = False
        'theCrystalReportViewer.DisplayGroupTree = False
        theCrystalReportViewer.ReportSource = oReport
        theCrystalReportViewer.DataBind()

        litMsg.Visible = False
        theCrystalReportViewer.Visible = True

将数据表变暗为数据表=tbl
thedata.TableName=“TableName”
Dim oReport作为新报告文档
Dim sRptPath As String=“…报告\MR01.rpt”
oReport.Load(sRptPath)
oReport.SetDataSource(数据表)
'oReport.SetDatabaseLogon(“#####,”、“###,”、“####,”、“####”
Dim c As ConnectionInfo=新的ConnectionInfo()
c、 ServerName=“#####”
c、 DatabaseName=“#####”
c、 Password=“#####”
c、 UserID=“#####”
c、 Type=connectionInfo.SQL
c、 IntegratedSecurity=False
对于i,将其作为整数=0发送到CrystalReportViewer.LogOnInfo.Count-1
theCrystalReportViewer.LogOnInfo(i).ConnectionInfo=c
下一个
'theCrystalReportViewer.EnableDatabaseLogonCompt=False
'theCrystalReportViewer.DisplayGroupTree=False
theCrystalReportViewer.ReportSource=oReport
theCrystalReportViewer.DataBind()
litMsg.Visible=False
theCrystalReportViewer.Visible=True

尝试按照此处的说明进行操作:

我认为你也需要摆脱这个:

    Dim c As ConnectionInfo = New ConnectionInfo()
    c.ServerName = "####"
    c.DatabaseName = "####"
    c.Password = "####"
    c.UserID = "####"
    c.Type = ConnectionInfoType.SQL
    c.IntegratedSecurity = False

    For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1
        theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c
    Next
JGauffin

和Lee一样,我很好奇为什么要加载带有存储过程数据的数据集,而不仅仅是将凭据传递给Crystal Report

事实上,您显示的代码甚至不会直接加载数据集。我建议您让报表使用存储过程直接从数据服务器提取数据。这只需要设置访问服务器的凭据

如果删除所有这些代码

Dim c As ConnectionInfo = New ConnectionInfo()
c.ServerName = "####"
c.DatabaseName = "####"
c.Password = "####"
c.UserID = "####"
c.Type = ConnectionInfoType.SQL
c.IntegratedSecurity = False

For i As Integer = 0 To theCrystalReportViewer.LogOnInfo.Count - 1
theCrystalReportViewer.LogOnInfo(i).ConnectionInfo = c
Next
。。。您可以重新引入这种方便的方法:

// this line needs you to replace these arguments with the valid values
oReport.SetDatabaseLogon("your", "valid", "settings", "here");
然后,如果只看到分页、打印和导出方面的问题,则应确保将ReportSource设置回视图

if (!IsPostBack) 
{
// all your existing code should go in here
// this includes the SetDatabaseLogon etc.
// at the right moment, save your oReport in session
Session["myReportDocument"] = oReport;
theCrystalReportViewer.ReportSource = oReport;
}
else // we are posting back, so make sure the viewer still has the report object
{
theCrystalReportViewer.ReportSource = (ReportDocument)Session["myReportDocument"];
}

我希望这能让你走上正确的道路。

谢谢你,但这并不是我想要的。本文展示了如何手动填充自定义数据集并将其推送到报表中。我想创建一个由存储过程填充的自定义数据集,并将其推送到报表中。通过数据集传递存储过程结果而不是将报表直接连接到存储过程的目的是什么?