1197214 - How to access a password protected MS-Access database?

SAP Knowledge Base Article - Public

1197214 - How to access a password protected MS-Access database?

Symptom

 

Need to access a password protected MS-Access database using VB .NET

Resolution

The following Visual Basic.NET sample code demonstrates how to access a password protected Ms-Access database programmatically.

-------------------------------------------------------------------------------------------------

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

 

Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim report As New SampleReport

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ConfigureCrystalReports()

    End Sub

 

Private Sub ConfigureCrystalReports()

 

        Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo

 

        crConnectionInfo.ServerName = (Application.StartupPath & "\Sample.mdb")

        crConnectionInfo.Password = "TEST"

        setDBLogonForReport(crConnectionInfo, report)

        CrystalReportViewer1.ReportSource = report

 

    End Sub

    Private Sub setDBLogonForReport(ByVal connection As ConnectionInfo, ByVal report As ReportDocument)

        Dim mytables As Tables = report.Database.Tables

        Dim mytable As CrystalDecisions.CrystalReports.Engine.Table

 

        For Each mytable In mytables

            Dim mytablelogoninfo As TableLogOnInfo = mytable.LogOnInfo

            mytablelogoninfo.ConnectionInfo = connection

            mytable.ApplyLogOnInfo(mytablelogoninfo)

        Next

    End Sub

End Class

-------------------------------------------------------------------------------------------------

 This will resolve the issue.

Keywords

accessing a password protected Ms-Access database , 3277751 , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008