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!

Setting connection info on Crystal 9 report from ASP

Status
Not open for further replies.

kdadswell

Programmer
Jul 28, 2002
3
AU
I have successfully written some ASP apps to launch reports that set database connection info, selection formula, etc at runtime using Crystal 8 and we are about to migrate to Crystal 9. There are no sample ASP apps (that are useful!) on the CD. I am wondering if any of you have tried to do this? It seems the way of setting up a report in ASP has changed radically from 8.x to 9.

Any help, links or hints would be greatly appreciated.
 
Thanks to the helpful staff at Crystal Decisions an answer was provided. Cr 9 uses a very different architecture than cr8/8.5. Here is the code to set the db logon...

' This function logs onto the datbase.
'

Function SetLogonInformation(UID, PWD)
Dim PropertyBag, dbLogonInfos, cDBInfo
Set PropertyBag = Server.CreateObject("CrystalReports.PropertyBag")

' Usually when using the Property Bag it is a good idea to set the EnsureCapacity method as this will
' improve server performace. It will pre allocate memory for the array of items. With this example
' the method was used as we know the fixed number of items that we need to add.

With PropertyBag
.EnsureCapacity (8)
.Item("All") = true
.Item("IncludeOnDemandSubreport") = false
.Item("UserName") = cStr(UID)
.Item("Database DLL") = "Pdsodbc.dll"
.Item("Database Name") = "pubs"
.Item("Server Name") = "pubs"
.Item("Server Type") = "ODBC - pubs"
End With

' The GetConnectionInfos will return a collection of all the database connection logons on the report
' including subreport logons. We set the attributes of the connection to be the information that we have
' stored in the property bag. For security reasons the password cannot be stored in the property bag.
' This method is better than using the ConnectionInfo object as it will not return subreport logon information.

set cDBInfo =
Session("ReportDoc").DatabaseController.GetConnectionInfos(PropertyBag)

For each oDBInfo in cDBInfo
oDBInfo.Attributes = PropertyBag
oDBInfo.Password = cStr(PWD)
Next

Session("ReportDoc").DatabaseController.SetConnectionInfos(cDBInfo)
End Function

'
' ------------------------------------------------------------------------

This is the original code sent to me by Crystal. I modified the code to work for my particular instance.

Once I got the hang the new architecture, I managed to set the selection formula too. A formula object needs to be created then set. For further details email me on kim.dadswell@qr.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top