Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon Failed using Push Method 1

Status
Not open for further replies.

TheStriker

Programmer
Aug 19, 2002
109
US
I have been trying for weeks to get rid of this error but it just won't seem to go away. I have googled high and low and found nothing. I know it is probably a simple solution to this very common error but it eludes me.

The skinny:

I am just a guy trying to impress his boss by embedding Crystal Reports in my ASP.Net application and this error has been haunting me for the better half of a month and I am at my wits end. I've tried every walkthrough, code sample, push-pull method, recommendation I could find but still no joy. I have found success when using one table with no params but for this report I must be able to use an SP with four tables.

The scenario:

I am a web developer and DBA for my application and I have all the appropriate permissions to perform most of the admin functions on the DB when I need to. I use my machine to test locally then copy my project to the production web server for use on our intranet. Again, I have had success in the past with CR.NET on my local machine with single tables as my datasource but this time I need to use a stored procedure with four tables.

The code:
Here is my page load event that I am currently using.

The Push Method using a dataset with a stored procedure.
Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim rpt As New CrystalReport1
        Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
        Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
        Dim crTable As CrystalDecisions.CrystalReports.Engine.Table

        daSiteGroup.Fill(DsSiteGroup1, "Site_Group_Rpt")
        crDatabase = rpt.Database
        crTables = crDatabase.Tables
        For Each crTable In crTables
            crTable.SetDataSource(DsSiteGroup1)
        Next
        CrystalReportViewer1.ReportSource = rpt

The connection string:
Code:
workstation id=<my workstation ID>;packet size=4096;user id=<my user ID>;data source="<my Server/datasource>";persist security info=True;initial catalog=<my database>;password=<my password>
Please note that I used the wizard to create this connection string.

Please feel free to point out anything that could be producing this elusive 'Logon Failed' error.

Thanks in advance for your help. :)
 
I GOT IT!!!!! WOW!!

I finally got it, although I am a few hair strands short from when I started this project, but it is all worth it. Thank you dvannoy for all your patience and help.

It turns out that your code, although well-written, was missing one ever-important line of code:

Code:
crDatabase = rpt.Database
        crTables = crDatabase.Tables
        For Each crTable In crTables
            crTable.SetDataSource(dsSiteGroup1)
       [BLUE]     rpt.SetDatabaseLogon("<userid>","<password>","<servername>","<database>")[/BLUE]
        Next

Please note that you must logon to every table within the stored procedure before Crystal renders the report or else the error will return. Again, thanks dvannoy for all your help. Have a star on me!!!
 
Thanks

Hmmm..I didn't need that but that's good to know.

glad it worked

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top