Public Class Form5
Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
caricaReport("C:\SanFrancesco\SanFrancesco.mdb")
End Sub
Private Sub caricaReport(ByVal pathDatabase As String)
Dim mioreport1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
mioreport1.Load(AppDomain.CurrentDomain.BaseDirectory & "\CrystalReport1.rpt")
Dim logOnInfo As New CrystalDecisions.Shared.TableLogOnInfo
logOnInfo = mioreport1.Database.Tables.Item("Schedepersonali").LogOnInfo
logOnInfo.ConnectionInfo.ServerName = pathDatabase
logOnInfo.TableName = "Schedepersonali"
mioreport1.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
CrystalReportViewer1.Visible = True
End Sub
Private Sub Form5_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub CrystalReportViewer1_Load(sender As Object, e As EventArgs) Handles CrystalReportViewer1.Load
CrystalReportViewer1.Visible = False
Try
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
Dim objdoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim varformula As String
varformula = "{Schedepersonali.codice}= " & Form3.CodiceTextBox.Text
CrystalReportViewer1.SelectionFormula = varformula
CrystalReportViewer1.RefreshReport()
objdoc.Load(Application.StartupPath & "\crystalreport1.rpt")
For Each tbCurrent In objdoc.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
'.ServerName = myDataSource
.UserID = ""
.Password = ""
.DatabaseName = "SanFrancesco"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
CrystalReportViewer1.ReportSource = objdoc
CrystalReportViewer1.RefreshReport()
Catch ex As Exception
End Try
CrystalReportViewer1.Visible = True
End Sub
End Class