Что такое правильная форма для отчета программы Crystal в asp.net?и Visual Basic - PullRequest
5 голосов
/ 05 августа 2011
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
    Dim rptv As New rptVenta()
    Session("vseleccionada") = GridView1.SelectedRow().Cells(1).Text.ToString()
    Dim daove As New DAOVenta()
    Dim tabla As New DataTable()
    tabla = daove.ImprimirFactura(Session("vseleccionada").ToString(), Session("nombreusuario").ToString())
    'Label2.Text = tabla.Rows(0)(3).ToString()
    '  rptv.SetDatabaseLogon("ventas.triton", "triton")
    '   rptv.SetDatabaseLogon("ventas.triton", "triton", "alumno-auc", "admodos")

    rptv.SetDataSource(tabla)
    rptv.SetDatabaseLogon("ventas.triton", "triton", ".", "admodos")

    CrystalReportViewer1.ReportSource = rptv
    rptv.Load("..\GUI\rptVenta.rpt")
    CrystalReportViewer1.LogOnInfo().Item(0).ConnectionInfo().DatabaseName = "admodos"
    CrystalReportViewer1.LogOnInfo().Item(0).ConnectionInfo().IntegratedSecurity = True
    CrystalReportViewer1.LogOnInfo().Item(0).ConnectionInfo().Password = "triton"
    CrystalReportViewer1.LogOnInfo().Item(0).ConnectionInfo().ServerName = "."
    CrystalReportViewer1.LogOnInfo().Item(0).ConnectionInfo().UserID = "ventas.triton"
    ' CrystalReportSource1.ReportDocument.SetDatabaseLogon("USER", "PASSWORD", "SERVIDOR", "Base de datos")
    CrystalReportViewer1.BackColor = Drawing.Color.White

    'CrystalReportViewer1.DataBind()

    Label2.Text = Session("vseleccionada").ToString() + Session("nombreusuario").ToString()

End Sub

я получил ошибку, как это

The report requested additional information needed.

тогда, каков правильный шаг, чтобы это заработало?Я программирую в Visual Basic, Visual Studio 2008, SQL Server 2008 R2.

1 Ответ

0 голосов
/ 12 августа 2011

Я получил эту ошибку раньше. Я не могу точно вспомнить, как я это исправил (это случилось 2-3 года назад), но вот код из проекта. Мне пришлось преобразовать его в VB, но я скомпилировал его и запустил, и он работал нормально. Кстати, это было на странице веб-формы ASP.Net, так что это из кода позади. Код со страницы просто имеет CrystalReportViewer.

Рекомендации:

  • CrystalDecisions.CrystalReports.Engine
  • CrystalDecisions.Enterprise.Framework
  • CrystalDecisions.Enterprise.InfoStore
  • CrystalDecisions.ReportSource
  • CrystalDecisions.Shared
  • CrystalDecisions.Web

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared

    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        ConfigureCrystalReports()

    End Sub

    Private Sub ConfigureCrystalReports()
        Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
        myConnectionInfo.DatabaseName = "ReportDatabase"
        myConnectionInfo.UserID = "ReportUser"
        myConnectionInfo.Password = "ReportPassword"
        myConnectionInfo.ServerName = "ReportServer"
        Dim ParamArrayList As ArrayList = New ArrayList()

        aReport = New ReportDocument()
        Dim reportPath As String = Server.MapPath("Report\ReportName.rpt")
        aReport.Load(reportPath)

        Dim Param as ArrayList 
        Param.Add("Value")

        SetCurrentValuesForParameterField(aReport, Param, "@Param1")
        myCrystalReportViewer.ReportSource = aReport 
        SetDBLogonForReport(myConnectionInfo, aReport)

    End Sub

    Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
        Dim myTables As Tables = myReportDocument.Database.Tables
        For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
           Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
           myTableLogonInfo.ConnectionInfo = myConnectionInfo
           myTable.ApplyLogOnInfo(myTableLogonInfo)
        Next
    End Sub

        Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal myArrayList As ArrayList, ByVal ParameterFieldName As String)
            Dim currentParameterValues As ParameterValues = New ParameterValues()

            For Each submittedValue As Object In myArrayList
                Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
                myParameterDiscreteValue.Value = submittedValue.ToString()
                currentParameterValues.Add(myParameterDiscreteValue)
            Next

            Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
            Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(ParameterFieldName)
            myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
        End Sub

        Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal myArrayList As ArrayList, ByVal ParameterFieldName As String, ByVal SubReportName As String)
            Dim currentParameterValues As ParameterValues = New ParameterValues()

            For Each submittedValue As Object In myArrayList
                Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
                myParameterDiscreteValue.Value = submittedValue.ToString()
                currentParameterValues.Add(myParameterDiscreteValue)
            Next

            Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
            Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(ParameterFieldName, SubReportName)
            myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
        End Sub
...