franckmj
Bovino adicto
- Desde
- 1 Sep 2007
- Mensajes
- 978
- Tema Autor
- #1
Hola compañeros bakunos nuevamente molestando :mota::mota::mota: pero ahora me surgiuo un pequeño problema tengo una pequeño sistemita que estoy desarrollando en ASP.net con el visual 2005 y genero un reporte con el crystal pero mis problemas por que son 2 son que puse un boton de mostrar reporte y el otro de exportar y ninguno de los dos me sirve
espero me puedan horientar en como hacerle de antemano muchas gracias aki les dejo mi codigo

Código:
******************* Este es el evento del boton*******************
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim clase As New class1
clase.showreport(llenardatos(lblerror.Text), Server.MapPath("reportelista.rpt"), Me.CrystalReportViewer1, lblcontador.Text)
Me.CrystalReportViewer1.Visible = True
If Me.lblerror.Text = "False" Then
Me.lblerror.Text = ""
End If
End Sub
****************Con esta "Hago mi consulta para llenar el reporte"*********
Private Function llenardatos(ByRef strerror As String) As DataSet
Dim strcon As String
Dim clase As New class1
strcon = "select nombre_alumno,apellidos,curso,lugar_curso,mes,año from tb_listas where mes'" & ddlmes.SelectedValue & "' and curso='" & ddlcurso.SelectedItem.Text & "' and lugar_curso='" & ddlsede.SelectedItem.Text & "'"
Dim ds As New DataSet
ds = clase.consulta(strcon, strerror)
If strerror = "False" Then
Return ds
Else
lblerror.Text = strerror
End If
End Function
******** Este es supuestamente el que debe mostrar el reporte **************
Public Sub showreport(ByVal ds As DataSet, ByVal rpt As String, ByVal crv As CrystalReportViewer, ByRef registros As String)
Dim oRpt As New ReportDocument
oRpt.Load(rpt)
oRpt.Database.Tables(0).SetDataSource(ds.Tables(0))
crv.ReportSource = oRpt
crv.DataBind()
registros = "registros = " & ds.Tables("table").Rows.Count
End Sub
Código:
********** Evento boton **********************************
Protected Sub btnexportar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnexportar.Click
exportreport(llenardatos(Me.lblerror.Text))
End Sub
******Funcion de exportacion********************************
Private Sub exportreport(ByVal dsdatos As DataSet)
Dim crd As New ReportDocument
crd.Load(Server.MapPath("reportelista.rpt"))
nombreReporte += "Reporte Listas"
crd.Database.Tables(0).SetDataSource(dsdatos.Tables("table"))
Dim rptStream As New System.IO.MemoryStream
Try
rptStream = CType(crd.ExportToStream(CInt(Me.ddlopciones.SelectedValue)), System.IO.MemoryStream)
Catch ex As Exception
Me.lblerror.Text = ex.Message & " en " & ex.Source
End Try
Response.Clear()
Response.Buffer = True
'Le indicamos el tipo de documento que vamos a exportar
Response.ContentType = FormatoDocumento()
'Automaticamente se descarga el archivo
Response.AddHeader("Content-Disposition", "attachment;filename=" + Me.nombreReporte)
'Se escribe el archivo
Response.BinaryWrite(rptStream.ToArray())
Response.End()
End Sub