Print Page | Close Window

Getting login prompt

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=352
Printed Date: 19 May 2024 at 3:47am


Topic: Getting login prompt
Posted By: techie3
Subject: Getting login prompt
Date Posted: 19 Mar 2007 at 9:52am
I created a report with many subreports.  On my test environment the entire report runs fine.  On the development server, I am getting prompted for login.  How do I resolve it?



Replies:
Posted By: BrianBischof
Date Posted: 19 Mar 2007 at 12:00pm
Read the entire thread here:

http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=342 - http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=342


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: techie3
Date Posted: 20 Mar 2007 at 8:55am

For some reason it didn't work.  Perhaps I didn't have it placed correctly. I have a lopp through each subreport and if there is a match for a specific subreport name then 'setdatasource'.  End of loop I set the viewer's reportsource.  I call a routine (setDbLogonForSubreports) to get the login info before the subreport loop.  But I am still getting prompted.

 

Sub SetDBLogonForSubreports()

Dim crConnectioninfo As ConnectionInfo

crConnectioninfo = New ConnectionInfo

Dim crTableLogOnInfo As TableLogOnInfo

Dim ServerName As String = "xxxxx"

Dim UserID As String = "xxxxxx"

Dim Password As String = "xxxxx"

Dim DatabaseName As String = "xxxxx"

'pass the necessary parameters to the connectionInfo object

With crConnectioninfo

.ServerName = ServerName

.UserID = UserID

.Password = Password

.DatabaseName = DatabaseName

End With

'set up the database and tables objects to refer to the current report

crDatabase = crReportDocument.Database

crTables = crDatabase.Tables

'loop through all the tables and pass in the connection info

For Each crTable In crTables

crTableLogOnInfo = crTable.LogOnInfo

crTableLogOnInfo.ConnectionInfo = crConnectioninfo

crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

'Loop through the sections in the main report to find the subreport objects

'then open the subreport and set the datasource to the subreport

For Each crSection In crSections

crReportObjects = crSection.ReportObjects

For Each crReportObject In crReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

'open the subreport object

crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = crSubreportDocument.Database

crTables = crDatabase.Tables

'loop through all the tables in the subreport and

'set up the connection info and apply it to the tables

For Each crTable In crTables

'MessageBox.Show(crTable.Name)

With crConnectioninfo

.ServerName = ServerName

.DatabaseName = DatabaseName

.UserID = UserID

.Password = Password

End With

crTableLogOnInfo = crTable.LogOnInfo

crTableLogOnInfo.ConnectionInfo = crConnectioninfo

crTable.ApplyLogOnInfo(crTableLogOnInfo)

Next

End If

Next

Next

End Sub



Posted By: techie3
Date Posted: 20 Mar 2007 at 11:13am
Resolved, I had used 2 different references of the main report; one that sets the datasource and another where the connection info was held.  There should be just one reference to the main report.


Posted By: BrianBischof
Date Posted: 20 Mar 2007 at 11:45am
glad you resolved it.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window