How to open more than 2 databases simultaneously in access protected with password in Crystal Report

1

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()
    
asked by Eduardo 26.10.2016 в 02:57
source

1 answer

0

It really is something simple, avoiding having a password in the database.

We create an Auxiliar.mdb database that does not contain a password. We create tables that we use in the other databases. I clean the tables if they contain information. I add the information only of what I need to show in the report within the tables. We read directly the report of this database that does not contain a password. I finish reading the report and delete the information.

Simple without complications

Greetings

    
answered by 17.11.2016 в 19:27