VS2008中的Crystal Report不会在Web上显示数据

时间:2012-03-16 22:37:11

标签: asp.net visual-studio-2008 crystal-reports

我的Visual Studio 2008中的水晶报告存在问题,搜索和搜索后我什么都没有。

我的文件CrystalReportxxx.rpt有一个xsd文件作为dataschema。创建一个数据表,并将其作为数据源传递给报告。为了填充数据表,我的应用程序连接到Oracle数据库。

要使用CrystalReportViewer显示行或数据,报表需要凭据,如数据库的logid和密码。但是,如果我将此报告导出为PDF文件,则不需要凭据,PDF文件显示所有行。

这是我的代码:

      Dim dt As DataTable 
        FunctionsOP.CreaDataTable("pkg_list.sp_list", True, ospEntry, 
dt) 
        Dim oRpt As New Reportes.CrystalReportxxx 
        oRpt.SetDatabaseLogon("userxxx", "passwordxxx") 
        oRpt.SetDataSource(dt) 
        CrystalReportViewer1.EnableDatabaseLogonPrompt = False
        CrystalReportViewer1.ReportSource = oRpt 
        CrystalReportViewer1.DataBind() 
        CrystalReportViewer1.Dispose() 

我想在设置时:         oRpt.SetDatabaseLogon(“userxxx”,“passwordxxx”) 和报告显示没有数据,是因为凭据错误。

我的问题是:如何绕过此凭证输入?

在我的Crystal中使用xsd文件是否必须输入用户ID,密码等 报告?

对我来说,奇怪的是,当我将该报告导出为PDF时,没有 问题。数据显示正常,无需凭证:

    Dim exportOpts As ExportOptions = oRpt.ExportOptions 
        oRpt.ExportOptions.ExportFormatType = 
ExportFormatType.PortableDocFormat 
        oRpt.ExportOptions.ExportDestinationType = 
ExportDestinationType.DiskFile 
        oRpt.ExportOptions.DestinationOptions = New 
DiskFileDestinationOptions 
        CType(oRpt.ExportOptions.DestinationOptions, 
DiskFileDestinationOptions).DiskFileName = Server.MapPath("../Temp/" + 
PDFName) 
        oRpt.Export() 
        oRpt.Close() 
        oRpt.Dispose() 

我也试过这段代码:

  Dim dt1 As New DataTable : Dim dt2 As New DataTable
    Dim oRpt As New Reportes.CR_IndicadorA11
    Dim ParRep As ReportClass = oRpt
    SetConnectionsReports(ParRep)
    FunctionsOP.CreaDataTable("pkg_Listar_Tipos.sp_indicador_a11_sum", True, Nothing, dt1)
    FunctionsOP.CreaDataTable("pkg_Listar_Tipos.sp_indicador_a11_det", True, Nothing, dt2)
    oRpt.SetDataSource(dt1)
    oRpt.OpenSubreport("CR_sub_indicadorA11_det.rpt").SetDataSource(dt2)

    CrystalReportViewer1.Visible = True
    CrystalReportViewer1.EnableDatabaseLogonPrompt = False
    CrystalReportViewer1.ReportSource = oRpt
    CrystalReportViewer1.DataBind()
    CrystalReportViewer1.Dispose()

    Public Sub SetConnectionsReports(ByRef Rpt As ReportClass)
            Dim server, base, user, pass As String

            server = "SRVBDDESA2.DOMINTERN0XXX.LOCAL" ' also with IP number is the same

            base = "DESAOPINT"
            user = "ORGPOL"
            pass = "desarrollo"

            For Each connection As IConnectionInfo In Rpt.DataSourceConnections
                connection.SetConnection(server, base, user, pass)
            Next
    End Sub

0 个答案:

没有答案