Private Sub ConfigureCrystalReports() Dim reportPath As String = Server.MapPath("CryRptCobranzat.rpt") Mi_Reporte = New ReportDocument() Mi_Reporte.Load(reportPath) Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() myConnectionInfo.ServerName = ".\SQLEXPRESS" myConnectionInfo.DatabaseName = "BD" myConnectionInfo.UserID = "user" myConnectionInfo.Password = "pasw" SetDBLogonForReport(myConnectionInfo, Mi_Reporte) With CRVW_detcorgdelearning .ReportSource = Mi_Reporte .SelectionFormula = "{TC_RUTAS_HM.rut_id_num} = 14" .RefreshReport() End With 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 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) End Sub
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
ConfigureCrystalReports() End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Unload Mi_Reporte.Close() Mi_Reporte.Dispose() End Sub