|    
			
				15/09/2005, 08:27
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: marzo-2005 
						Mensajes: 123
					 Antigüedad: 20 años, 7 meses Puntos: 1 |  | 
  |  Exportar archivo en Crystal Reports  
  Hola se que me van a mandar links relacionados con el tema pero ya los he visto y no esta lo que busco. 
 Bueno lo que pasa es que tiro un formulario y por pantalla sale ok...
 pero al exportarlo a un archivo pdf me selecciona el primero que esta ingresado en la base de datos y no el que quiero.....
 
 aca esta el codigo.... de antemano muchas gracias
 
 ' por pantalla funciona perfecto....
 ' me muestra el documento 556
 
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
 
 Dim rptExpensiveProducts As New ReportDocument
 Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
 Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
 
 
 Try
 rptExpensiveProducts.Load("f:\Inetpub\wwwroot\WebC  rystal\CrystalReport3.rpt")
 
 For Each tbCurrent In rptExpensiveProducts.Database.Tables
 tliCurrent = tbCurrent.LogOnInfo
 With tliCurrent.ConnectionInfo
 .ServerName = "compras"
 .UserID = "compras"
 .Password = "compras"
 .DatabaseName = ""
 End With
 tbCurrent.ApplyLogOnInfo(tliCurrent)
 Next tbCurrent
 
 CrViewer.SeparatePages = False
 CrViewer.DisplayGroupTree = False
 CrViewer.DisplayToolbar = False
 
 
 CrViewer.ReportSource = rptExpensiveProducts
 CrViewer.SelectionFormula = "{E_SOLICITUD.SC_IDENTIF}=556"
 
 
 CrViewer.Zoom(2)
 CrViewer.DataBind()
 
 Catch Exp As LoadSaveReportException
 
 Catch Exp As Exception
 
 End Try
 end sub
 
 
 'pero al tirarlo a un archivo (pdf), me toma el primer registro ingresado en la base de datos
 'como lo hago para que me exporte el documento que yo quiero
 
 
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
 Dim rptSolcompras As New ReportDocument
 Dim odbConnection As New OleDb.OleDbConnection
 
 Dim odbData As New Data.DataSet
 Dim x As Integer
 Dim comm As OleDb.OleDbCommand
 
 rptSolcompras.Load("f:\Inetpub\wwwroot\WebCrystal\  CrystalReport3.rpt")
 
 odbConnection = New OleDb.OleDbConnection("Provider=msdaora;User ID=compras;Data Source=test;Password=compras")
 
 Dim Da_E_Solicitud As New OleDb.OleDbDataAdapter("SELECT * FROM E_SOLICITUD WHERE SC_IDENTIF=556", odbConnection)
 Dim Da_D_Solicitud As New OleDb.OleDbDataAdapter("SELECT * FROM D_SOLICITUD WHERE SC_IDENTIF=556", odbConnection)
 Dim xpv_rut As String
 
 Dim ds As New DataSet
 Dim dt As DataTable
 
 Dim xCC_CODID As Integer
 Dim xFN_CODID As Integer
 Dim xMIT_CODIGO As Integer
 
 
 Da_E_Solicitud.Fill(ds, "E_SOLICITUD")
 
 xpv_rut = ds.Tables.Item(0).Rows(0).Item(9)
 xCC_CODID = ds.Tables.Item(0).Rows(0).Item(3)
 xFN_CODID = ds.Tables.Item(0).Rows(0).Item(4)
 xMIT_CODIGO = ds.Tables.Item(0).Rows(0).Item(10)
 
 Dim Da_M_PROVEEDOR As New OleDb.OleDbDataAdapter("SELECT * FROM M_PROVEEDOR WHERE trim(PV_RUT)='" & Trim(xpv_rut) & "'", odbConnection)
 Dim Da_M_CENCOS As New OleDb.OleDbDataAdapter("SELECT * FROM M_CENCOS WHERE CC_ID=" & xCC_CODID, odbConnection)
 Dim Da_M_FONDOS As New OleDb.OleDbDataAdapter("SELECT * FROM M_FONDOS WHERE MFN_CODIGO=" & xFN_CODID, odbConnection)
 Dim Da_M_ITEM As New OleDb.OleDbDataAdapter("SELECT * FROM M_ITEM WHERE MIT_CODIGO=" & xMIT_CODIGO, odbConnection)
 
 
 Da_D_Solicitud.Fill(ds, "D_SOLICITUD")
 Da_M_PROVEEDOR.Fill(ds, "M_PROVEEDOR")
 Da_M_CENCOS.Fill(ds, "M_CENCOS")
 Da_M_FONDOS.Fill(ds, "M_FONDOS")
 Da_M_FONDOS.Fill(ds, "M_ITEM")
 
 
 rptSolcompras.Load("f:\Inetpub\wwwroot\WebCrystal\  CrystalReport3.rpt")
 
 rptSolcompras.SetDataSource(ds)
 
 Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
 Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
 
 For Each tbCurrent In rptSolcompras.Database.Tables
 tliCurrent = tbCurrent.LogOnInfo
 With tliCurrent.ConnectionInfo
 .ServerName = "compras"
 .UserID = "compras"
 .Password = "compras"
 .DatabaseName = ""
 End With
 tbCurrent.ApplyLogOnInfo(tliCurrent)
 Next tbCurrent
 
 CrViewer.ReportSource = rptSolcompras
 
 CrViewer.DataBind()
 
 ' exporto a un pdf
 
 Dim exportO As ExportOptions
 Dim req As ExportRequestContext
 Dim st As System.IO.Stream
 Dim b() As Byte
 Dim pg As Page
 
 pg = CrViewer.Page
 exportO = New ExportOptions
 exportO.ExportFormatType = ExportFormatType.PortableDocFormat
 exportO.FormatOptions = New PdfRtfWordFormatOptions
 req = New ExportRequestContext
 req.ExportInfo = exportO
 With rptSolcompras.FormatEngine.PrintOptions
 .PaperSize = PaperSize.PaperLegal
 .PaperOrientation = PaperOrientation.Portrait
 End With
 st = rptSolcompras.FormatEngine.ExportToStream(req)
 pg.Response.ClearHeaders()
 pg.Response.ClearContent()
 pg.Response.ContentType = "application/pdf"
 ReDim b(st.Length)
 st.Read(b, 0, CInt(st.Length))
 pg.Response.BinaryWrite(b)
 pg.Response.End()
 End Sub
     |