Data source connection properties

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

Data source connection properties


 







When changing a data source connection, you must specify the connection properties in your ConnectionInfo object. Specify these properties in a CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag object and set them using the CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo.Attributes property. There are two distinct sets of properties to define values for:

Every general kind of data source (CrystalDecisions.ReportAppServer.DataDefModel.CrConnectionInfoKindEnum) has a set of default properties that can be set. For example, you can set the following properties for all Crystal Report Query Engine (CRQE) connections:

Visual Basic

Dim QEProperties As PropertyBag = New PropertyBag()
QEProperties.Add("Database DLL", "crdb_xml.dll");
QEProperties.Add("QE_DatabaseName", "DBName");
QEProperties.Add("QE_DatabaseType", "User friendly database type description");
QEProperties.Add("QE_ServerDescription", "User friendly server description");
QEProperties.Add("QE_SQLDB", True);
QEProperties.Add("SSO Enabled", False);

C#

PropertyBag QEProperties = new PropertyBag();
QEProperties.Add("Database DLL", "crdb_xml.dll");
QEProperties.Add("QE_DatabaseName", "DBName");
QEProperties.Add("QE_DatabaseType", "User friendly database type description");
QEProperties.Add("QE_ServerDescription", "User friendly server description");
QEProperties.Add("QE_SQLDB", true);
QEProperties.Add("SSO Enabled", false);

Each data source type has a different set of required logon properties. Store these properties in a second PropertyBag object and set them as the value of the "QE_LogonProperties" key for the main connection properties. Here is an example for connecting to a local XML data source:

Visual Basic

Dim QELogonProperties As PropertyBag = New PropertyBag()
QELogonProperties.Add("Local XML File", "C:\\customer.xml");
QELogonProperties.Add("Local Schema File", "C:\\customer.xsd");
QELogonProperties.Add("Convert Mulitivalue to Table", False);
QEProperties.Add("QE_LogonProperties", QELogonProperties);

C#

PropertyBag QELogonProperties = new PropertyBag();
QELogonProperties.Add("Local XML File", "C:\\customer.xml");
QELogonProperties.Add("Local Schema File", "C:\\customer.xsd");
QELogonProperties.Add("Convert Mulitivalue to Table", false);
QEProperties.Add("QE_LogonProperties", QELogonProperties);

NoteTip

To more easily identify the key-value pairs of connection properties you can change for your data source, iterate through the property bag of an existing connection in a report (created through the Crystal Reports Designer) using the ConnectionInfo.Attributes property. The value of the "QE_LogonProperties" key is itself a property bag, and must be iterated through to obtain the specific values.

Visual Basic

Private Sub DataSourceConnectionProperties(ByVal oldConnectionInfo As ConnectionInfo)
 Dim oldPb As PropertyBag = oldConnection.Attributes
 For Each attribute As String In oldPb.PropertyIDs
  If oldPb.Item(attribute).ToString().Equals("System.__ComObject") Then
   Response.Write(attribute & " (" & oldPb.Item(attribute).GetType().ToString() & ") = <br>")
   Dim oldLogonPb As PropertyBag = oldPb.Item(attribute)  
   For Each logonAttribute As String In oldLogonPb.PropertyIDs
    Response.Write(logonAttribute & " = " & oldLogonPb.Item(logonAttribute).ToString() & " (" & oldLogonPb.Item(logonAttribute).GetType().ToString() & ")<br>")
   Next
  Else
   Response.Write(attribute & " = " + oldPb.Item(attribute).ToString() & " (" & oldPb.Item(attribute).GetType().ToString() + ")<br>")
  End If
 Next
End Sub

C#

private void DataSourceConnectionProperties(ConnectionInfo oldConnectionInfo)
{
 PropertyBag oldPb = oldConnection.Attributes;
 foreach (String attribute in oldPb.PropertyIDs)
 {
  if (oldPb[attribute].ToString().Equals("CrystalDecisions.ReportAppServer.DataDefModel.PropertyBagClass"))
  {
   Response.Write(attribute + " (" + oldPb[attribute].GetType().ToString() + ") = <br>");
   PropertyBag oldLogonPb = (PropertyBag)oldPb[attribute];
   foreach (String logonAttribute in oldLogonPb.PropertyIDs)
   {
    Response.Write(logonAttribute + " = " + oldLogonPb[logonAttribute].ToString() + " (" + oldLogonPb[logonAttribute].GetType().ToString() + ")<br>");
   }
  }
  else
  {
   Response.Write(attribute + " = " + oldPb[attribute].ToString() + " (" + oldPb[attribute].GetType().ToString() + ")<br>");
  }
 }
}

NoteTip

To access all the connections located in a report you can use the DatabaseController.GetConnectionInfos method. You can iterate through each ConnectionInfo in the ConnectionInfos class, and then identify their properties.

Visual Basic

Public Sub AllDataSourceConnectionProperties(ByVal rcd As ISCDReportClientDocument)
 Dim databaseController As DatabaseController = rcd.DatabaseController
 Dim connectionInfos As ConnectionInfos = databaseController.GetConnectionInfos(Nothing)
 For Each connectionInfo As ConnectionInfo in connectionInfos
  ...
 Next
End Sub

C#

public void AllDataSourceConnectionProperties(ISCDReportClientDocument rcd)
{
 DatabaseController databaseController = rcd.DatabaseController;
 ConnectionInfos connectionInfos = databaseController.GetConnectionInfos(null);
 foreach (ConnectionInfo connectionInfo in connectionInfos)
 {
  ...
 }
}

NoteNote

While the above example passes in null or Nothing into the DatabaseController.GetConnectionInfos method, it's parameter is a PropertyBag object that can be used to prompt the database for only the connections that have the same attributes as the passed PropertyBag.

This list includes the namespaces used by the sample code:

© 2021 SAP AG. All rights reserved.

http://www.sap.com/sapbusinessobjects/

Support services

http://service.sap.com/bosap-support/

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation