Klipfolio Dashboard 5 API

Object Engines.ODBC

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

This object is only available in a licensed version of Klipfolio Dashboard. In order to use 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: Cookbook article on ODBC Klips.


Nested Object Summary
<static class> Engines.ODBC.ODBCResponse
 
Properties Summary
 Engines.ODBC.ODBCResponse response
           The response instance.
   
Function Summary
 function connect()
           Connects to a specified database.
 function disconnect()
           Disconnects from a specified database.
 function newConnectionnewDataSource( <String> connectionstring )
           Configures a new data source.
 function sendQuery()
           Sends a query to the database.
 function setQuery( <String> query )
           Sets up the database object with a query.

Properties Detail

response

Engines.ODBC.ODBCResponse response

Function Detail

connect

function connect()

disconnect

function disconnect()

newConnectionnewDataSource

function newConnectionnewDataSource( <String> connectionstring )

sendQuery

function sendQuery()

setQuery

function setQuery( <String> query )

Klipfolio Dashboard 5 API

© 2009 Klipfolio Inc. All Rights Reserved.