Visual Studio 2005 / ASP.NET / Crystal Reports / Access Database / Logon Failed

Posted on 2006-06-27
Last Modified: 2012-06-21
I created a ASP.NET Web site using Visual Studio 2005.  The site contains a simple crystal report linked to an Access database.  The report pulls up fine on my local development PC but when I deploy it to the Web server, I get a 'Logon Failed' message.  The Access database is NOT password protected.  What do I need to add to my code-behind to get this to work?  So far, I just have the following.  The name of my report is CrystalReport1.rpt.  Thanks for your help!


Partial Class _Default
    Inherits System.Web.UI.Page

End Class
Question by:drees727
  • 5
  • 3

Expert Comment

ID: 16994743
May be the next code can help you:
It is necessary to add a user and a password although exist not.
For example:
This is a list of reports

Select Case Me.ListBoxReportes.SelectedItem.Value
                    Case "Date"
                        DateApplicantReport.SetDatabaseLogon("USER", "PASSWORD")
                        ViewReports.ReportSource = Me.DateApplicantReport
End Select
Catch err as Exception
          "Error Message"

LVL 25

Expert Comment

ID: 16995518
Whare is the access file located?  If it;s on a network share, you'll ned to use impersonation and possibly delegation in order to access the Access file - no pun intended:).

Add <identity impersonate="true"/> to web.config as a start.

Author Comment

ID: 16995623
The Access db is located on a network share.  I added <identity impersonate="true"/> and now I'm getting a 'Load report failed' message.
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 25

Expert Comment

ID: 16995846
The bottom line is probably that the user that the web app is running as does not have access to te network share.  You have several  options:

1) Impersonate a domain account by using
<identity impersonate="true" userName="{domain\username}" password="{password}"  />
in web.config

2) Do not use identity impersonate=true and give the computer account access to the database file

3) Use delegation by adding
<identity impersonate="true" />
to web.config and set up the web server to be trusted for delegation in Active Directory

4) Put the access file on the web server

Author Comment

ID: 17003415
With the Access file on the Web server, I get the message:

The report you requested requires further information.
Server name:    \\servername\db.mdb
Database name:    \\servername\db.mdb
User name:    limitedPermissionAccount
 Use Integrated Security  

I am able to connect the the same database and display information via an ASP.NET gridview.  It seems to be just when I try to incorporate a crystal report that I get the login prompt.

I've tried several variations on the following code-behind and still get the login prompt.  The code seems to be more geared to SQL Server and I'm using Access.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Partial Class _Default
    Inherits System.Web.UI.Page

        Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
        myConnectionInfo.DatabaseName = "db"
        myConnectionInfo.UserID = "USER"
        myConnectionInfo.Password = "PASSWORD"
        myConnectionInfo.ServerName = "servername"
        Dim reportPath As String = Server.MapPath("CrystalReport1.rpt")
        myCrystalReportViewer.ReportSource = reportPath

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    End Sub

    Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)
        Dim myTableLogOnInfos As TableLogOnInfos = myCrystalReportViewer.LogOnInfo
        For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
            myTableLogOnInfo.ConnectionInfo = myConnectionInfo

    End Sub
End Class
LVL 25

Accepted Solution

dstanley9 earned 125 total points
ID: 17003502
Sorry, I don't know much about Crystal, but I found the following at

• If you are reporting off an Access database, then
specify either the 'ServerName' or 'DatabaseName'
to the 'ConnectionInfo' Object depending on
how you are connecting to Access.

For example, if you are connecting to Access
through ODBC, then set the 'DatabaseName' for the
'ConnectionInfo' object as follows:

With crConnectionInfo
.DatabaseName = "C:\mydatabase\mydata.mdb"
End With

If you are connecting to Access through OLE DB,
then set set the 'ServerName':

With crConnectionInfo
.ServerName = "C:\mydatabase\mydata.mdb"
End With

It is not possible to report of a secured Access
database using a native connection. See knowledge
base article C2010460 for more information.

Author Comment

ID: 17044626
I'm connecting to Access through OLE DB and I've modified my code as follows.  Now when I pull up the page, I get an 'Access is Denied' message when it hits

I AM able to successfully view a report in the same folder that is connected to Oracle.  

All help is appreciated!


        Dim crDatabase As Database
        Dim crReport = New ReportDocument()
        Dim crTables As Tables
        Dim crTable As Table
        Dim crTableLogOnInfo As TableLogOnInfo
        Dim crConnectionInfo As ConnectionInfo

        crConnectionInfo = New ConnectionInfo()

        With crConnectionInfo
            .ServerName = "\\Webserver\database\cr.mdb"
        End With

        crDatabase = crReport.Database
        crTables = crDatabase.Tables

        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo

        CrystalReportViewer1.ReportSource = crReport

Author Comment

ID: 17044779
I modified my crReport.Load to:

Now I'm back to getting:
The report you requested requires further information.
Server name:    
Database name:    
User name:    

I'm about to give up on trying to connect to Access and just work with Oracle.

Author Comment

ID: 17103276
I just realized my problem.  I had to change:




Thanks for your help!


Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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