Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/09/2011, 14:23
sAnto0s
 
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 10 meses
Puntos: 3
Respuesta: generar pdf desde un informe en RP

Hola, consegui hacerle despues de algunos, solo que no pude subirlo antes...
lo tengo puesto y no me ha dado problemas... espero y te funcione...



Código:
Public Sub showBitacora(ByVal query As String)
        Try
            Me.lblError.Text = ""
            '[Inicia proceso para mostrar reporte]
            sqlConn.ConnectionString = strConn

            If sqlConn.State = ConnectionState.Closed Then
                sqlConn.Open()
            End If

            strQuery = query 'consulta para llenar el dataset

            cmd = New SqlCommand

            cmd.Connection = sqlConn
            cmd.CommandText = strQuery
            cmd.CommandType = CommandType.Text
            ds = New DataSet

            da.SelectCommand = cmd
            da.Fill(ds, "catBitacora")

            strReportName = "rptBitacora.rpt"          

            Dim strPath As String = Server.MapPath("Reports\" & strReportName)
            Dim rptDoc As New ReportDocument

            rptDoc.Load(strPath)
            rptDoc.SetDataSource(ds)

            '---> crear pdf
            Response.Buffer = False
            '// Clear the response content and headers               
            Response.ClearContent()
            Response.ClearHeaders()

            Try               
                rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "SGI")

            Catch ex As Exception        
                lblError.Text = ex.Message

            End Try

        Catch ex As Exception         
            lblError.Text = ex.InnerException.Message

        Finally
            If sqlConn.State = ConnectionState.Open Then
                sqlConn.Close()
            End If
        End Try
    End Sub

Esta funcion la tngo en mi pag con el crystalviewer (crv) y solo la mando llamar en el load....