Establishing a Connection
 
 
 

As mentioned in a previous section, Connection Semantics, the FDO API uses a provider to connect to a data store and its underlying data source technology. These data source technologies must be installed and configured. Certain values generated during data source installation and configuration are used as arguments during the connection process. Because the FDO API does not provide any methods to automate the collection and presentation of these configuration values, either the application developer must request the user to input these configuration values during the connection process, or the application developer can provide an application configuration interface, which would populate the application with the container configuration values and thus allow the user to choose them from lists.

NoteFor more information about connecting, see The Essential FDO.

A connection can be made in either one or two steps:

Connecting to a data store by way of the Oracle or the ArcSDE provider, for example, can be done in either one or two steps. In the first step, the data store parameter is not required. If the user does not give the data store parameter a value, the FDO will retrieve the list of data store values from the data source so that the user can choose from them during the second step. Otherwise the user can give the data store a value in the first step, and assuming that the value is valid, the connection will be completed in one step.

The following steps are preliminary to establishing a connection:

  1. Get the display names for all of the providers in the registry.
  2. Use the display names to create a menu list, which the user will select from when making a connection.

After the user initiates a connection attempt, do the following:

  1. Loop through the providers in the registry until you match the display name selected by the user from the connection menu with a provider display name in the registry and retrieve the internal name for that provider.
  2. Get an instance of the connection manager.
  3. Call the manager’s CreateConnection() method using the provider internal name as an argument to obtain a connection object.
  4. Obtain a connection info object by calling the connection object’s GetConnectionInfo() method.
  5. Obtain a connection property dictionary object by calling the connection info object’s GetConnection Properties() method and use this dictionary to construct a dialog box requesting connection information from the user.
  6. Get a list of connection property names by calling the dictionary’s GetPropertyNames() method and loop through the list constructing a data entry line in the dialog box for each name in the list.
  7. Use the GetLocalizedName method to obtain the label for the data entry line in the dialog.
  8. Use the IsPropertyRequired method to determine whether to mark the line as either required or optional; the dialog box handler should not permit the user to click OK in the dialog box unless a required field has a value.
  9. Use the IsPropertyProtected method to determine whether the dialog box handler should process the field value as protected data.
  10. Use the IsPropertyEnumerable method to determine whether to call the EnumeratePropertyValues method to get a list of valid values. Then,

If IsPropertyEnumerable returns True and EnumeratePropertyValues sets the updates count parameter to 0, then grey (make unavailable) this line in the dialog;

If the count is 1, set the line value to the value in the returned list;

If the count is greater than 1, then set up a spin box for this line containing the list of values and then call the GetProperty method;

If this method returns a value that is in the list, set the exposed spin-box value in the dialog box line to this value;

If this method returns the empty string, call the GetPropertyDefault method and if this returns a value that is in the list, and set the exposed spin-box value in the dialog box line to this value;

Otherwise, set the exposed spin-box value to some value in the returned list.

  1. If the property is not enumerable, call the GetProperty method to determine whether you get a non-empty return value, set the value for that line in the dialog box to the return value.
  2. If the property is not enumerable and does not yet have a value, call the GetPropertyDefault method and set the value for that line in the dialog box to the return value.
  3. After processing each property in the dictionary, expose the dialog.
  4. After the user has okayed the connection dialog box and the dialog box handler has determined that all of the required information has been filled in, the dialog box handler uses the dictionary’s SetProperty() method to update the dictionary with the values specified by the user.
  5. Call the connection object’s Open() method and check the returned connection state value; if the value is FdoConnectionState_Pending, then reconstruct the connection dialog box and present it to the user for further input.
  6. If the return value is FdoConnectionState_Open, the connection process is complete.