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. :)
 
Is the error referring to Cryastal Reports, or when you try to fill the dataset?
 
Hello jbenson001,

I can't tell exactly when the error occurs however I am familiar with the dataset error because it references it in the error page. There was no such referrence this time. It could be with Crystal Reports although I am willing to explore both possibilities. Please advise.
 
Still have not managed to resolve this issue and it's driving me nuts. There is nothing in google that seems to fit my scenario.
 
OK, I have managed to get the report to run with no fields from the Db but once I add a field, the error returns. Any advice?
 
check you ASPNET permissions. You may have to add it to the ADMIN's group.

also, see if you have a virtual directory pointed to

C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Viewers



 
another thing I noticed about crystal reports is even if you create a dataset with user name and password it seems like that's not enough to open the report. it's like it needs to log back into the DB to get the data. I use a connection string as I load the page. selecting my fields from the dataset that is linked to my stored procedure.

 
Can you post a sample of the connection string you used?

How do I check ASPNET permissions?
 
right click "my computer" go to manage then users and groups check if ASPNET is in the Administrators group.

Dim cn As SqlConnection = New SqlConnection()
Dim YourDataset As New DataSet()
Dim strSQL As String

cn.ConnectionString = "Data Source=server ip address;" & _
"Initial Catalog=DBName;" & _
"User Id=sa;" & _
"Password=xxxx"

Dim cmd As New SqlCommand()

With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "Your SP Name"
End With

Dim DA As New SqlDataAdapter(cmd)

cn.Open()

DA.Fill(YourDataset, "Your SP Name")

crDatabase = crReportDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTable.SetDataSource(YourDataset)
Next

rptPO.ReportSource = crReportDoc



 
I've added ASPNET to the Administrators Group successfully and I tried your code while filling in my info and I still get the same error:

Logon Failed.
Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

This is very confusing considering the data is already in the dataset and it just needs to be pushed to the report document which could mean the problem is in Crystal Reports. I successfully binded other controls to the same dataset.

Here is the code I used:
Code:
        Dim rpt As New CrystalReport1
        Dim crDatabase = rpt.Database
        Dim crTable As Table
        Dim crTables As Tables
        Dim cn As SqlClient.SqlConnection = New SqlClient.SqlConnection
        Dim dsSiteGroup1 As New DataSet
        Dim strSQL As String

        cn.ConnectionString = "Data Source=S0B1066\S0B1066;" & _
        "Initial Catalog=ptsup;" & _
        "User Id=bosspts;" & _
        "Password=ddpmsboss"

        Dim cmd As New SqlClient.SqlCommand

        With cmd
            .Connection = cn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "Site_Grp_Rpt"
        End With

        Dim daSiteGroup As New SqlClient.SqlDataAdapter(cmd)

        cn.Open()

        daSiteGroup.Fill(dsSiteGroup1, "Site_Grp_Rpt")

        crDatabase = rpt.Database
        crTables = crDatabase.Tables
        For Each crTable In crTables
            crTable.SetDataSource(dsSiteGroup1)
        Next
        CrystalReportViewer1.ReportSource = rpt
 
do you have a virtual directory pointed to the crystal reports viewer folder?

 
I just created a virtual directory that points to the Crystal Reports Viewer Folder.
 
Do I create a blank report first then add the fields from the dataset via the code you provided? What is the sequence of events? Maybe I'm missing something.
 
I don't create blank reports...create your report from the dataset. then add your fields from there. were you creating a blank report?

 
I was using the wizard to create the report using the datasets I also created using the wizard. Do these items need to be deleted and then run your code again or does it matter?
 
download the above file...once you get past this, you will understand and find it easier. trust me..I pulled my hair out as well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top