ASP.NET/Crystal Reports Logon Failed

Discussion in 'ASP .Net' started by mollyf@hotmail.com, Feb 24, 2005.

  1. Guest

    I have tried various suggestions that I have found searching the
    newsgroups and still haven't been able to figure why I keep getting the
    logon failed error.

    I created a report in Crystal (not via VS 2003). The data source to
    the report is a stored procedure (SQL S2K) that has no parameters. I'm
    also using SQL Server authentication to log in.

    I added the report to my project (as was suggested recently by someone
    in a different thread). I have tried the following code:

    Dim myReport As New ProvidersList

    Dim conStrBH As String =
    ConfigurationSettings.AppSettings("conStrBH")
    Dim cnn As SqlConnection = New SqlConnection(conStrBH)
    Dim cmd As New SqlCommand
    Dim ProvIDParam As New SqlParameter
    Dim i As Integer

    cnn.Open()
    cmd.Connection = cnn
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = "sp_GetProviders"

    myReport.Database.Tables(0).SetDataSource(cmd)
    myReport.Load()
    CrystalReportViewer1.ReportSource = myReport
    cnn.Close()

    conStrBH is a connection string located in the web.config and is used
    throughout the app. There is no problem with the connection string as
    I wouldn't be able to log into the web app if there was a problem
    there.

    I've also tried the following code, which is similar to what VS help
    showed.

    Dim myReport As New ProvidersList
    Dim logOnInfo As New TableLogOnInfo
    Dim i As Integer

    For i = 0 To myReport.Database.Tables.Count - 1
    ' Set the connection information for current table.
    logOnInfo.ConnectionInfo.ServerName = "servername"
    logOnInfo.ConnectionInfo.DatabaseName = "databasename"
    logOnInfo.ConnectionInfo.UserID = "username"
    logOnInfo.ConnectionInfo.Password = "password"

    myReport.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
    Next i
    myReport.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
    myReport.Load()
    CrystalReportViewer1.ReportSource = myReport


    In both cases, I get the same error:

    CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

    I'm doing this on my local machine running Win XP Pro. Any help would
    be appreciated.

    Thanks.

    Molly J. Fagan
    Oklahoma Foundation for Medical Quality
     
    , Feb 24, 2005
    #1
    1. Advertising

  2. Vaibhav Guest

    I think you need to load the report first and then provide the logon info.

    > >>>>>>>>. myReport.Load()<<<<<<<<<<<<<<<<



    > For i = 0 To myReport.Database.Tables.Count - 1
    > ' Set the connection information for current table.
    > logOnInfo.ConnectionInfo.ServerName = "servername"
    > logOnInfo.ConnectionInfo.DatabaseName = "databasename"
    > logOnInfo.ConnectionInfo.UserID = "username"
    > logOnInfo.ConnectionInfo.Password = "password"
    >
    > myReport.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
    > Next i
    > myReport.Database.Tables(0).ApplyLogOnInfo(logOnInfo)


    > CrystalReportViewer1.ReportSource = myReport


    HTH

    <> wrote in message
    news:...
    >I have tried various suggestions that I have found searching the
    > newsgroups and still haven't been able to figure why I keep getting the
    > logon failed error.
    >
    > I created a report in Crystal (not via VS 2003). The data source to
    > the report is a stored procedure (SQL S2K) that has no parameters. I'm
    > also using SQL Server authentication to log in.
    >
    > I added the report to my project (as was suggested recently by someone
    > in a different thread). I have tried the following code:
    >
    > Dim myReport As New ProvidersList
    >
    > Dim conStrBH As String =
    > ConfigurationSettings.AppSettings("conStrBH")
    > Dim cnn As SqlConnection = New SqlConnection(conStrBH)
    > Dim cmd As New SqlCommand
    > Dim ProvIDParam As New SqlParameter
    > Dim i As Integer
    >
    > cnn.Open()
    > cmd.Connection = cnn
    > cmd.CommandType = CommandType.StoredProcedure
    > cmd.CommandText = "sp_GetProviders"
    >
    > myReport.Database.Tables(0).SetDataSource(cmd)
    > myReport.Load()
    > CrystalReportViewer1.ReportSource = myReport
    > cnn.Close()
    >
    > conStrBH is a connection string located in the web.config and is used
    > throughout the app. There is no problem with the connection string as
    > I wouldn't be able to log into the web app if there was a problem
    > there.
    >
    > I've also tried the following code, which is similar to what VS help
    > showed.
    >
    > Dim myReport As New ProvidersList
    > Dim logOnInfo As New TableLogOnInfo
    > Dim i As Integer
    >
    > For i = 0 To myReport.Database.Tables.Count - 1
    > ' Set the connection information for current table.
    > logOnInfo.ConnectionInfo.ServerName = "servername"
    > logOnInfo.ConnectionInfo.DatabaseName = "databasename"
    > logOnInfo.ConnectionInfo.UserID = "username"
    > logOnInfo.ConnectionInfo.Password = "password"
    >
    > myReport.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
    > Next i
    > myReport.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
    > myReport.Load()
    > CrystalReportViewer1.ReportSource = myReport
    >
    >
    > In both cases, I get the same error:
    >
    > CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
    >
    > I'm doing this on my local machine running Win XP Pro. Any help would
    > be appreciated.
    >
    > Thanks.
    >
    > Molly J. Fagan
    > Oklahoma Foundation for Medical Quality
    >
     
    Vaibhav, Feb 24, 2005
    #2
    1. Advertising

  3. Guest

    Thanks for your quick response. Unfortunately, your suggestion didn't
    work for either of the ways I'm trying.
     
    , Feb 24, 2005
    #3
  4. Vaibhav Guest

    mentioned below is my code which work fine on my machine. code is invoked
    from within
    Private Sub Page_Init()

    crReportDocument.Load(Server.MapPath("crXYZ.rpt"),
    OpenReportMethod.OpenReportByTempCopy)

    With crConnectionInfo

    .ServerName = "XYZ"

    .DatabaseName = "SOMEDB"

    .UserID = "SOMEUSERID"

    .Password = "SOMEPASS"

    End With

    crTables = crReportDocument.Database.Tables

    'sets connection info. for database tables

    For Each crTable In crTables

    crtableLogoninfo = crTable.LogOnInfo

    crtableLogoninfo.ConnectionInfo = crConnectionInfo

    crTable.ApplyLogOnInfo(crtableLogoninfo)

    Next

    'sets the report source

    CrystalReportViewer1.ReportSource = crReportDocument

    End Sub

    HTH

    <> wrote in message
    news:...
    > Thanks for your quick response. Unfortunately, your suggestion didn't
    > work for either of the ways I'm trying.
    >
     
    Vaibhav, Feb 24, 2005
    #4
  5. Guest

    What kind of objects are crTables and crTable? I found some code
    similar to yours and guessed at what types they could be but still
    haven't had any luck.

    Thanks so much for your help.
     
    , Feb 24, 2005
    #5
  6. Vaibhav Guest

    crTables --is a collection of table object(i.e. crTable)

    HTH

    <> wrote in message
    news:...
    > What kind of objects are crTables and crTable? I found some code
    > similar to yours and guessed at what types they could be but still
    > haven't had any luck.
    >
    > Thanks so much for your help.
    >
     
    Vaibhav, Feb 25, 2005
    #6
  7. Guest

    I'm still getting the logon failed error. Below is all of my code. I
    no longer have the report as part of the project. Is there something
    that I need to do to the server to make it work? I'm hitting the
    database to log into my web app but I don't know if there's additional
    steps needed for Crystal that I'm missing or what.

    Thanks for your help.


    Dim crConnectionInfo As New
    CrystalDecisions.Shared.TableLogOnInfo
    Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
    Dim crReportDocument As New
    CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
    Dim crtableLogoninfo As CrystalDecisions.Shared.TableLogOnInfo
    crReportDocument.Load(Server.MapPath("ProvidersList.rpt"),
    OpenReportMethod.OpenReportByTempCopy)

    With crConnectionInfo.ConnectionInfo
    .ServerName = "server"
    .DatabaseName = "database"
    .UserID = "user"
    .Password = "password"
    End With

    crTables = crReportDocument.Database.Tables

    'sets connection info. for database tables

    For Each crTable In crTables
    crtableLogoninfo = crTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo =
    crConnectionInfo.ConnectionInfo
    crTable.ApplyLogOnInfo(crtableLogoninfo)
    Next

    'sets the report source

    CrystalReportViewer1.ReportSource = crReportDocument
     
    , Feb 28, 2005
    #7
  8. Stacy Dudas Guest

    I am having a similar issue. I am using Crystal Reports 10 and Delphi
    7. My development database is different than my production database.
    In previous versions of Crystal (9 and 8.5) I was able to delete the DSN
    and table owner from the Crystal application - Database | Set Location,
    Table edit box on the bottom of the screen.
    ie. from dsn_name.dbo.tablename to tablename

    This worked with my production and development reports when called
    through Delphi.

    Crystal 10 does not allow the changing of the table under the set
    location. I am receiving the "Logon failed" error as well.

    Do you have any suggestions?

    Thanks,
    Stacy

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Stacy Dudas, Mar 1, 2005
    #8
  9. I was getting the same error when using the ApplyLogOnInfo method
    against a stored proc.

    I gave execute permissions for the user i was logging on as to the
    stored proc (should have done that in the first place but forgot) and it
    worked.

    Hope that helps.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Nate Papineau, Mar 14, 2005
    #9
  10. Joseph Bowen Guest

    This problem is bedeviling me too. Here is a Microsoft note on the
    issue:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;319264

    Beware, their example code is written in C#.

    But, this doesn't fix my problem. I am working within VS, and created
    the report and the webpage with the report viewer in the designer. I
    theorize that the report I'm setting the logon info for is not the same
    instance as the report that is being shown, the one created in the
    designer. Anybody familiar with this issue?

    I've tried
    setting logon userid/pw
    changing ASPNET user's permissions
    try/catch statements
    and am lost. Any thoughts welcome.

    Joe



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joseph Bowen, Mar 15, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo Marchesoni

    Logon failed with Crystal Reports

    Carlo Marchesoni, Aug 20, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    824
  2. igitur
    Replies:
    3
    Views:
    9,971
    sprit01
    Apr 2, 2007
  3. GFro
    Replies:
    2
    Views:
    3,826
    Gregg Froelich
    Jul 23, 2004
  4. Milan Todorovic

    Crystal Reports 'Logon failed' problem

    Milan Todorovic, Feb 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    11,212
    =?Utf-8?B?Q2hyaXM=?=
    Mar 18, 2005
  5. Peri
    Replies:
    1
    Views:
    3,099
    =?Utf-8?B?Um90aGFyaWdlcg==?=
    Jul 21, 2005
Loading...

Share This Page