Klipfolio Dashboard 5 API

Object Engines.ODBC

Object
   |
   +--Klip
         |
         +--Engines
               |
               +--Engines.ODBC

Advanced Feature This object is only available in a licensed version of Klipfolio Dashboard. To try it in Klipfolio Personal Dashboard, add <enterprise>true</enterprise> in your <setup> block.

The Engines.ODBC object provides access to the ODBC APIs.

The following example prints out the data source in the Debug Window.

 var odbc = 0;
 function onRefresh()
 {
	if (!odbc)
	{
 	// Set the connection string
 	var odbc = Engines.ODBC.newDataSource("Provider=sqloledb;
 		Data Source=myServerAddress;Initial Catalog=myDataBase;
		User Id=myUsername;Password=myPassword");

	// Or, in case of Active Directory:
 	// var odbc = Engines.ODBC.newDataSource("Provider=sqloledb;
	//	Data Source=myServerAddress;Initial Catalog=myDataBase;
	//	Integrated Security=SSPI;");

	 }

	// If connection to the database is successful, proceed with the query
 	if (odbc.connect ())
 	{
		// Set up the database object with a query
 		odbc.setQuery("SELECT * FROM Production.Product
				WHERE ProductID < 300");

 		// Or, for a stored procedure:
 		// odbc.setQuery( "EXEC dbo.uspGetEmployeeManagers 6" );

		// Send the query to the database
 		if (odbc.sendQuery ())
 		{
			// If the query is successfully sent, get the response object
			// in XML format
 			var query_resp = odbc.response.xml;

			// Print out the XML data in Debug Window
			trace( query_resp );
 		}

		// Disconnect from the database
 		odbc.disconnect ();
 	}

	// Return the XML data for Klipfolio Dashboard to parse using
	// stylesheet settings
	return Engines.Data.process (query_resp);

 }
 

Stylesheet Format

The returned XML is formatted z:row tags. Each row contains the list of columns as attributes within the z:row tag. The Klip's <style> block must be organized in the following manner in order for the returned XML data to be parsed:

 <style>
 	z:row::attribute( columnHeaderName ) {
  		...
  		}
 	z:row::attribute( columnHeaderName ) {
  		...
  		}
 	z:row {
  		type: item;
  		definition: all;
  		}
 </style>
 

The order of the style entries is important. The item definition must follow the entry definitions.

See also:
How-to article on developing an ODBC Klip.


Nested Object Summary
<static class> Engines.ODBC.ODBCResponse
 
Properties Summary
 Engines.ODBC.ODBCResponse response
          Advanced Feature The response instance.
   
Function Summary
 function connect()
           Advanced Feature Connects to a specified database.
 boolean disconnect()
           Advanced Feature Disconnects from a specified database.
 String getLastError()
           Advanced Feature Gets the description of the most recent error.
 function newDataSource( <String> connectionstring )
           Advanced Feature Configures a new data source.
 boolean sendQuery()
           Advanced Feature Sends a query to the database.
 function setQuery( <String> query )
           Advanced Feature Sets up the database object with a query.

Properties Detail

response

Engines.ODBC.ODBCResponse response

Function Detail

connect

function connect()

disconnect

boolean disconnect()

getLastError

String getLastError()

newDataSource

function newDataSource( <String> connectionstring )

sendQuery

boolean sendQuery()

setQuery

function setQuery( <String> query )

Klipfolio Dashboard 5 API

© 2010 Klipfolio Inc. All Rights Reserved.