Thursday, March 22, 2012

can u help me to set dynamic database option to crystal reports

hi
I am having 120 crystal reports of 9 and when ever I want to change the DBuser I am facing problem and i have to change for all the 120 reports
IS THERE ANY EASY SOLUTION FOR ME..?
PL HELP ME...:thumb:Hi paste this code in all the view pages of the report and try ...this is working for me in XI verison.
Please do reply me after trying

'' New Code for Passing the DB in Run-Time for CR-XI
Set mainReportTableCollection = Session("oRpt").Database.Tables

For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = DB_UID
.Item("Password") = DB_PWD
.Item("DSN") = CRYSTAL_RPT_DSN
.Item("Database") = DB_NAME
End With
' response.write mnTable.ConnectionProperties.Item("DSN")
mnTable.Location = DB_NAME & ".dbo." & mnTable.name
'mnTable.Location ="crbard.dbo." & mnTable.name
Next

Dim CRXSections, CRXSection, CRXobject, CRXSubreport, CRXsubreports, CrSubtable
Set CRXSections = session("oRpt").Sections
For each CRXSection in CRXSections
For each CRXObject in CRXSection.ReportObjects
If CRXObject.Kind = 5 then 'Subreport
Set CRXSubreport = CRXObject.OpenSubreport
for each crSubTable in CRXSubreport.Database.Tables
' StripLocation(crSubTable)
' crSubTable.SetLogonInfo CRYSTAL_RPT_DSN,DB_NAME , DB_UID, DB_PWD

With crSubTable.ConnectionProperties
.Item("user ID") = DB_UID
.Item("Password") = DB_PWD
.Item("DSN") = CRYSTAL_RPT_DSN
.Item("Database") = DB_NAME
End With
crSubTable.Location = DB_NAME & ".dbo." & crSubTable.name
'crSubTable.Location = "crbard.dbo." & crSubTable.name
next
End IF
next
next
'' Code End for Passing the DB in Run-Time for CR-XI

No comments:

Post a Comment