Solved

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

Posted on 2006-06-27
9
3,698 Views
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
0
Comment
Question by:drees727
  • 5
  • 3
9 Comments
 

Expert Comment

by:DoradoITTeam
Comment Utility
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")
                        DateApplicantReport.SetDataSource(Me.DsAdmin.Tables("Applicants"))
                        ViewReports.ReportSource = Me.DateApplicantReport
                        Printing(DateApplicantReport)
End Select
Catch err as Exception
          "Error Message"


0
 
LVL 25

Expert Comment

by:dstanley9
Comment Utility
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.
0
 

Author Comment

by:drees727
Comment Utility
The Access db is located on a network share.  I added <identity impersonate="true"/> and now I'm getting a 'Load report failed' message.
0
 
LVL 25

Expert Comment

by:dstanley9
Comment Utility
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
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:drees727
Comment Utility
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
Password:    
 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
        SetDBLogonForReport(myConnectionInfo)

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

    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

        Next
    End Sub
End Class
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 125 total points
Comment Utility
Sorry, I don't know much about Crystal, but I found the following at http://support.businessobjects.com/library/kbase/articles/c2010371.asp:

• 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.
0
 

Author Comment

by:drees727
Comment Utility
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
crReport.Load("\\Webserver\myfolder\CrystalReport.rpt")

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
       
        crReport.Load("\\Webserver\myfolder\CrystalReport.rpt")

        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
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
        Next

        CrystalReportViewer1.ReportSource = crReport
0
 

Author Comment

by:drees727
Comment Utility
I modified my crReport.Load to:
crReport.Load(Server.MapPath("CrystalReport.rpt"))

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

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

Author Comment

by:drees727
Comment Utility
I just realized my problem.  I had to change:

crReport.Load("\\Webserver\myfolder\CrystalReport.rpt")

to

crReport.Load("c:\myfolder\CrystalReport.rpt")

Thanks for your help!

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now