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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass log on info to subreports as well?

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

This is what I do to pass log on info to the Crystal Reports.

<%
'------------------------------------------------------------------
' Working with SetLogOnInfo
'------------------------------------------------------------------
' The datasource here is called "DSNName". It is a System
' Datasource, and points to the "DBName" database, which is installed
' with SQL Server.

userid = "user"
password = "pwdpt"

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

' Set the location
set crtable = session("oRpt").Database.Tables.Item(1)
crtable.SetLogonInfo "DSNName", "DBName", cstr(userid), cstr(password)
%>

But this report has 17 sub-reports. All these reports also refer to the same database with same username and password. How can I pass the same logon info to each and every sub-reports?

Whatever parameter I am passing to the main report also works for the 17 sub-reports.

Please assist me here.
 
Hi
there is a bit of extra stuff here, but basically it is just loopint thru each sup report and setting the same information. this is asp.net using CR9 report engine.
crSections = crRepDoc.ReportDefinition.Sections
For Each crSection In crSections
crRepObjs = crSection.ReportObjects
For Each crRepObj In crRepObjs
If crRepObj.Kind = ReportObjectKind.SubreportObject Then
crSubRepObj = CType(crRepObj, SubreportObject)
Try
crSubRepDoc = crSubRepObj.OpenSubreport(crSubRepObj.SubreportName)
Catch engEx As OutOfLicenseException
CrystalErrorMessage = "Currently all of the available Crystal Reports Licenses are in use. Please wait a moment and try again."
WriteToReportLog(CrystalEventID, CrystalReportName, "Error Creating SubReport", engEX.Message)
Exit Sub
Catch engEx As EngineException
CrystalErrorMessage = engEx.Message
WriteToReportLog(CrystalEventID, CrystalReportName, "Error Creating SubReport", engEX.Message)
Exit Sub
End Try
crDatabase = crSubRepDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
With crConnInfo
If UseRptServer = True And ReportingServerOnline Then
.ServerName = ConfigurationSettings.AppSettings("ReportServerName")
.DatabaseName = ConfigurationSettings.AppSettings("ReportDatabaseName")
.UserID = ConfigurationSettings.AppSettings("ReportUserID")
.Password = ConfigurationSettings.AppSettings("ReportPassWord")
Else
.ServerName = ConfigurationSettings.AppSettings("OLEDBServerName")
.DatabaseName = ConfigurationSettings.AppSettings("OLEDBDatabaseName")
.UserID = ConfigurationSettings.AppSettings("OLEDBUserID")
.Password = ConfigurationSettings.AppSettings("OLEDBPassWord")
End If
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top