I would like to know how I can simultaneously open 3 or 4 password protected Access databases in Crystal Report.
Previously I read the topic " I can not open a crystal report with a Microsoft Access database with password ". I added the code for that answer and it works perfect for me when it's just a database.
When it is more than one database, it does not work, it only recognizes the tables of the last database that you read; and he sent me a notice that does not locate the tables that are inside the other databases.
Dim cryRpt As New ReportDocument
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfos1 As New TableLogOnInfos()
Dim crtableLogoninfo1 As New TableLogOnInfo()
Dim crConnectionInfo1 As New ConnectionInfo()
Dim CrTables1 As Tables
Dim CrTable1 As Table
cryRpt.Load("C:\Repor\Nota2.rpt")
'----------------------------------------------------------------------------
With crConnectionInfo
.ServerName = ""
.DatabaseName = "C:\BASES DE DATOS\FACTNH.mdb"
.UserID = ""
.Password = pwxmen
End With
CrTables = cryRpt.Database.Tables
'For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
With crConnectionInfo1
.ServerName = ""
.DatabaseName = "C:\BASES DE DATOS\REGISTRO.mdb"
.UserID = ""
.Password = pwxmen
End With
CrTables1 = cryRpt.Database.Tables
'For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
For Each CrTable1 In CrTables1
crtableLogoninfo1 = CrTable1.LogOnInfo
crtableLogoninfo1.ConnectionInfo = crConnectionInfo1
CrTable1.ApplyLogOnInfo(crtableLogoninfo1)
Next
'----------------------------------------------------------------------------
Reportes.CR1.ReportSource = cryRpt
Reportes.CR1.Refresh()
Reportes.CR1.Zoom(75)
Reportes.Show()