Wrox Programmer Forums
Welcome to the p2p.wrox.com Forums.

You are currently viewing the WinForms/Console Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 16th, 2009, 11:51 PM
Authorized User
Join Date: Aug 2006
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
Default Crystal Reports Logon Failed

I have developed an applicaion in vb.net which has a few crystal reports. I'm using MS Access database. Every thing is working fine on my development machine. But the logon failed error pops up on the deployment machine. I have googled for about a week now but to no avail. The code is as follows:

Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
Dim crDatabase As Database
Dim crTables As Tables
Dim aTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim repDoc as new Result 'Result is the report doc .rpt
ForEach myTable In repDoc.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.Password = ""
myLogin.ConnectionInfo.UserID = "Admin"
crSections = repDoc.ReportDefinition.Sections
'loop through all the sections to find all the report objects
ForEach crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects in there to find all subreports 
ForEach crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
crSubreportObject = CType(crReportObject, SubreportObject)
'open the subreport object and logon as for the general report
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables
ForEach aTable In crTables
crTableLogOnInfo = aTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo.UserID = "Admin"
crTableLogOnInfo.ConnectionInfo.Password = ""
'crTableLogOnInfo.ConnectionInfo.DatabaseName = Application.StartupPath & "\Taxi Training Software Db.mdb"
CrystalReportViewer1.ReportSource = repDoc

One thing i dont understand is what should i specify as Server name for Access DB.

Kindly, plz help me if u know whats wrong or if u know the solution to this problem.

Old January 17th, 2009, 09:42 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

Hello. And did you try taking everything out?? why login to an access database that doesn't have a password nor an user?


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
================================================== =========
I know that CVS was evil, and now i got the
================================================== =========
Old January 17th, 2009, 11:35 AM
Authorized User
Join Date: Aug 2006
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts

Even I cannot understand that. It does not have any username and password. I did not have the above code included before. It was working fine on my development machine. Even now it is. But on another system... I can't find a way to make it work. I am so fed up and stuck in this. What I am thinking now is that it might not be an issue with the database. It might be an issue with the crystal reports. Please HELP!!! this is urgent as my project is lingering on just because of this stupid error.
Old January 19th, 2009, 12:36 PM
Authorized User
Join Date: Aug 2006
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts

Hi everyone,

I finally found out the solution to the problem myself.
Silly Errors are always the hardest ones to solve.
Same is the case over here.
As the Logon Dialog makes us all think that there's a great security issue associated with it, there isn't.

My mistake where i figured it out was that the report document uses the absolute full path of db included in the application.

So just modifying

ForEach myTable In repDoc.Database.Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.ServerName = Application.StartupPath & "\Db.mdb"
myLogin.ConnectionInfo.DatabaseName = Application.StartupPath & "\Db.mdb"
solved my problem.
I totally ommitted the Username and password and instead provided the path to the db.

Hope it might help someone else who is also banging his/her head in front of the PC like i did for over a week....

Last edited by The Beginner; January 19th, 2009 at 12:41 PM..
Old October 4th, 2010, 03:03 AM
Authorized User
Join Date: Jun 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal Reports Login

here is complete example



Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report Logon failed mrleaps ASP.NET 1.0 and 1.1 Professional 1 October 13th, 2005 01:06 PM
Crystal Reports ActiveX Designer : Logon failed. thangna BOOK: Professional Crystal Reports for VS.NET 2 November 24th, 2004 06:37 AM
Crystal Reports ActiveX Designer Logon failed thangna Crystal Reports 1 November 11th, 2004 08:40 PM
crystal reports .net designer login failed error dilshan Crystal Reports 3 September 23rd, 2004 01:38 PM
Logon failed... exporting crystal reports into pdf JerBlur VB.NET 0 July 23rd, 2004 02:00 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.