cancel
Showing results for 
Search instead for 
Did you mean: 

Login failed error on CR from VB.Net

Former Member
0 Kudos

Hi Everyone,

I'm trying to integrate my existing crystal report into VB.Net. When I try to call the crystal report from my program, CR pops up a database login screen. After entering sa login and password, I get attached logon failed error. Can somebody please help me resolve this? My CR is very complicated and has 8 subreports to it.

Thanks,

Amol

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I was able to remove the login screen on CR load by setting:

rptdocument.SetDatabaseLogon("sa", "test123")


I no longer get the database login screen. But the report never loads up. I get the below screen message ending up with my screen getting freeze.


Any inputs on this will be very helpful. Thanks.


Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos

What version of CR? What CR Service Pack.

What database?

How are you connecting to the database?

Does the report work anywhere? In CR designer?

What version of .NET?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hi Ludek,

Below is the answer to your questions:


What version of CR? What CR Service Pack.

CrystalReports for Visual 2010.


What database?

Microsoft SQL Server 2008 R2.


How are you connecting to the database?

Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

            rptdocument.Load(strreportpath)

            rptdocument.SetDatabaseLogon("sa", "test123")

            rptdocument.SetDataSource(sqlds.Tables(0))

            CrystalReportViewer1.ReportSource = rptdocument

            CrystalReportViewer1.Refresh()


Does the report work anywhere? In CR designer?

Yes, the report works perfect in CR designer

What version of .NET?

Microsoft Visual Studio  2010

Version 10.0.40219.1 SP1Rel

I hope that helps. Thanks.

Regards,

Amol


0 Kudos

Hi Amol,

What Crystal service pack are you using?

Also, search, lots of post on the DB driver you should be using for that SQL Server.

And don't call refresh, that virtually reloads the reports default properties and therefore ignores your log on info.

You also have to set the log on info for each subreport, search, lots of samples on how to get the subreport objects and then set the log on info.

Don

former_member183750
Active Contributor
0 Kudos

Ok. I still do not know the CR Service pack you are using. So, go here and download SP 11.

For MS SQL Server 2008, make sure you are using SQL Native 10 or higher client.

For code, download the Developer Help file:

SAP Crystal Reports .NET SDK Developer Guide

Search for 'connect'. You will get a lot of help on best code. You can also look at sample apps here:

Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki

Samples csharp_win_dbengine.zip / vb_win_dbengine.zip

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hi Ludek,

As suggested, I've installed SP 11 on my machine.

Don,

I also got rid of CrystalReportViewer1.Refresh() from my code. Can you please give me hand on setting up dblogon for the subreports? Below is my code:

Thanks,

Amol

Imports CrystalDecisions.Shared

Imports CrystalDecisions.CrystalReports.Engine

Imports System.Data.SqlClient

Public Class Form2

    Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load

        Try

            strsql = "select * from JobHeader where Jobnumber='J004295'"

            Dim sqlda As New SqlDataAdapter(strsql, sqlconn)

            sqlda.Fill(sqlds, "table1")

            strreportname = "Report1"

            Dim strreportpath As String = Application.StartupPath & "\" & strreportname & ".rpt"

            If Not IO.File.Exists(strreportpath) Then

                Throw (New Exception("unable to locate report file: " & vbCrLf & strreportpath))

            End If

            Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

            rptdocument.Load(strreportpath)

            rptdocument.SetDatabaseLogon("sa", "test123")

            rptdocument.SetDataSource(sqlds.Tables(0))

            CrystalReportViewer1.ReportSource = rptdocument

            'CrystalReportViewer1.Refresh()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

End Class

former_member183750
Active Contributor
0 Kudos

Please, check the code in the sample csharp_win_dbengine.zip / vbnet_win_dbengine.zip at the link I provided in my previous post.

- Ludek

0 Kudos

Or search for kbase articles

Redirecting...

Don