Blog Series Part 1: Many Connection Types for the External Data Provider, there are

The External Data Provider is THE Swiss Army knife of the Toolset. Sure it connects to your external data, but did you realize all the connection types it supports and the possible properties you can specify with each? During this blog series we’ll cover all the connection types, the properties associated with them and also provide examples for you to reference going forward. This article assumes you have seen a connection file before and understand its format of an opening & closing <CorasWorks> parent element with each connection being stored as a <Data> element within.

So, without delay, let’s look at the first (and most common) connection type – ADO.

The ADO connection type is the method you’ll use when connecting to most traditional databases and legacy systems. Generally speaking, any data source that supports an OLEDB or ODBC connection has a connection string that can be used for accessing that data source. The most comprehensive listing of these connection strings can be found online at www.ConnectionStrings.com; when on the site, look for the “ADO” or “ADO.Net” version of a connection string for your data source. You can also find connection string details within a source’s documentation or SDK.

When creating an ADO connection, there are two properties specific to an ADO connection type: <ConnectionString> and <Query>. As with all connections, you will also need a <Name>, <Default> and <ConnectionType> property.

Thus, an ADO connection can be as basic as:

<Data>

<Name>YourConnectionName</Name>

<Default>True/False</Default>

<ConnectionType>ADO</ConnectionType>

<ConnectionString>YourConnectionString</ConnectionString>

<Query>Your SFW Query</Query>

</Data>

 

Now, let’s look at some of the additional properties that are optional for an ADO connection:

Property Name / Element

Property Use / Function

<OutputType>

When omitted, the default is “text/xml” however “text/html” and ”text/plain” are also supported

<XslStylesheet>

Actual XSL to transform the response from your Provider. However, it is recommended to use an attached stylesheet (see next property) as opposed to including your XSL in line here.

<XslStylesheetLocation>

The URL to the location of an XSL stylesheet (can be .xml, .xsl or .xslt) to be applied for transforming the Provider response. This transform occurs *before* the data is rendered or passed on to another component.

<ErrorRedirect>

A URL to redirect a user/connection to when the connection called results in an error.

<ReportErrors>

A true/false flag to indicate whether errors are reported. If set to “true”, and an <ErrorRedirect> is specified, the error message will be attached to the redirect URL as: ErrorRedirectURL?Error=(Error Message)

<RedirectTo>

The URL to redirect this connection to upon successful completion. This is the ability to take the response from one connection and instantly pass it into another to complete a process or validate a response. If you specify a parameter in the RedirectTo, you can pass the value of the initial connection using a pre-defined variable called %Data%.

Ex. http://site.net/subsite/providers/ADO.aspx?

ConnectionName=SecondConnection&FirstValue=%Data%

<RDConnection>

The URL to pass the results of this connection into. This is different than a <RedirectTo> which literally forwards the request on to a new page/connection. With an <RDConnection>, the results of the first connection are passed into a second connection for use in processing said connection, and the results of the second connection are then returned to the first one. This is most useful when needing to send a collection of XML into a second connection since, with the RedirectTo, the entire response of the first connection is passed via query string variable; see the next property for setting the XML elements you wish to post into the second connection.

<RDConnectionPost>

A property for specifying (via XPath) the XML results from your first connection that you wish to post into a second connection, as well as the parameter names to use when posting them. The <RDConnectionPost> also supports setting a default value to pass for a parameter, should the XPath for the parameter value not exist within the first connection’s result.

<Values>

The Values element simply holds empty child nodes representing each and every parameter that you wish to pass into this connection. Thus, if you plan to pass in a parameter called “Department” into your connection for use in your query, you would need a self-closing <Department /> element inside your <Values></Values> elements. This has the effect of letting the connection know to look for a GET/POST parameter with the name specified. There is no limit to the number of parameters you can list here.

<CacheOutput>

A true/false value indicating whether or not the output from this connection should be cached. If set to “true”, you can use the following three properties to customize the cache label and/or duration. Absent any of the following properties, the default label will be TheConnectionName+”Output”+WebPartID with a duration of 200 mins.

<CacheLabel>

A text value to specify the cache label; if not specified, the default Web Part ID will be used for this portion of the cache identifier.

<CacheAddUserID>

A true/false value indicating whether or not to add the ID of the user running the connection to cache label; this is akin to a cache per user mechanism. If set to “true” the User’s ID will be added to the end of the cache label.

<CacheDuration>

An integer value indicating the cache duration in minutes.

 

And just to make it all easier to hit the ground running, you can download a sample connection file with an ADO connection from the Building Block Exchange section of the CorasWorks Community forum here.

Check back tomorrow for Part 2 in the series – Web Service connections.

1 comment to Blog Series Part 1: Many Connection Types for the External Data Provider, there are

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>