Symptom
- It is often useful for an application developer to be able to determine which database connection properties are used by a report.
Resolution
- The connection properties associated with a report can be retrieved by using the following code in Visual Studio .NET.
Dim msg As String
Dim crTable As Table
Dim crLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim i As Integer
Dim crReportDocument as New CrystalDecisions.CrystalReports.Engine.ReportDocumentmsg = ""crReportDocument .Load(Application.StartupPath & "\<report name>")For Each crTable In crReportDocument.Database.TablescrLogOnInfo = crTable.LogOnInfo
crConnectionInfo = crLogOnInfo.ConnectionInfoFor i = 0 To crConnectionInfo.Attributes.Collection.Count - 1If TypeOf (CType(crConnectionInfo .Attributes.Collection(i), NameValuePair2).Value) Is CrystalDecisions.Shared.DbConnectionAttributes Thenmsg = msg & Environment.NewLineDim j As Integer
Dim nvs2 As NameValuePairs2nvs2 = CType(CType(crConnectionInfo.Attributes.Collection(i), NameValuePair2).Value, CrystalDecisions.Shared.DbConnectionAttributes).CollectionFor j = 0 To nvs2.Count - 1msg = msg & "DCA Attribute: " & CType(nvs2(j), CrystalDecisions.Shared.NameValuePair2).Name & " - "
msg = msg & CType(nvs2(j), CrystalDecisions.Shared.NameValuePair2).Value & Environment.NewLineNextmsg = msg & Environment.NewLineElsemsg = msg & CType(crConnectionInfo.Attributes.Collection(i), NameValuePair2).Name & " - "
msg = msg & CType(crConnectionInfo.Attributes.Collection(i), NameValuePair2).Value & Environment.NewLineEnd IfNext
NextMessageBox.Show(msg)
- Database connection properties can also be retrieved using the Report Application server (RAS) APIs for Visual Studio .NET.
- See the Report Application Server Database Connectivity wiki for more details.
Keywords
KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To
Product
Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio