Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Password protected Access database and Crystal Report

Posted on 2005-04-29
Medium Priority
Last Modified: 2008-01-09
I have problems with connecting MS Access 2000 database protected with password. I have tried to get help with this article: http://support.businessobjects.com/library/kbase/articles/c2010371.asp but could not get it work...

I have selected OLE DB connection from Desing window and created report without Database password.

Here is my code (I have used that article when creating it):  
The code works fine without password. When I'm settin password and running report, I get window "Database login" and it always says "logon failed".  If I try to connect database in Desing window, I get error: "Login Failed. Cannot start your application, the workgroup file is either missing or opened exclusively by another user."

Database location have to change when running, and I store right location from textfile.
I am using .NET 2003 and Crystal Report that came with.

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

     'Help from here: http://support.businessobjects.com/library/kbase/articles/c2010371.asp

        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table

        Dim crReportDocument As New CrystalReport1

        'getting database location (like c:\myDatabase.mdb)
        'Location is different than what is set in Design window
        Dim sr As New System.IO.StreamReader("datab.txt")
        Dim MyDatabase As String = sr.ReadLine()

        'Set the ConnectionInfo properties for logging on to
        'the Database
        With crConnectionInfo
            .ServerName = MyDatabase
            .UserID = "Admin"
            .Password = "MyPassword"
        End With

        ' Set the CrTables to the Tables collection of the report
        CrTables = crReportDocument.Database.Tables

        'Loop through each table in the report and apply the
        'LogonInfo information

        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo

        'Set the viewer to the report object to be previewed.
        CrystalReportViewer1.ReportSource = crReportDocument
    End Sub

Hope that someone can help me,
Question by:miuku
  • 2
LVL 77

Accepted Solution

peter57r earned 750 total points
ID: 13892915
Hi miuku,
This looks more relevant even though it's not the same version.


Author Comment

ID: 13893095
Thanks but it didn't help...

In .NET version of CR is no 'OLE BD' selection in 'More Data Sources'. Then I selected Access/Excel (DAO)  but there is no 'Data Link Properties' dialog box. I still get database working in Design window, but if I try to run report, i get same "Database login" window and it says that logon failed.

***Here is the code now:***      

       'Open an instance of the report in memory
        Dim CrTables As Tables
        Dim CrTable As Table
        Dim CrReport As New CrystalReport2

        CrTables = CrReport.Database.Tables

        'getting database location (like c:\myDatabase.mdb)
        'Location is different than what is set in Design window
        Dim sr As New System.IO.StreamReader("datab.txt")
        Dim MyDatabase As String = sr.ReadLine()

        'Loop through the tables collection and set the location of the access database for
        'each table.
        For Each CrTable In CrTables
            CrTable.Location =MyDatabase

        ' Set the report object as the report source for the viewer
        CrystalReportViewer1.ReportSource = CrReport

LVL 101

Expert Comment

ID: 13894279
Are you using the standard mdw file?

look at

Use the logon subreport sample


Author Comment

ID: 13976685
I worked out this problem. It works fine with Access/Excel (DAO) -connection if I use that first code. And don't ask why I changed code when trying peter57r's link.... =)

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question