CFLib.org – Common Function Library Project

IsDatasource(nameToCheck)

Last updated June 21, 2002

author

Nathan Dintenfass

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Pass in a string, get a boolean back telling you if a datasource of that name exists.

Return Values:
Returns a boolean.

Example:

<cfoutput>#isDatasource("cfsnippets")#</cfoutput>

Parameters:

Name Description Required
nameToCheck DSN to check for. Yes

Full UDF Source:

/**
 * Returns a boolean if the datasource name exists.
 * 
 * @param nameToCheck      DSN to check for. (Required)
 * @return Returns a boolean. 
 * @author Nathan Dintenfass (nathan@changemedia.com) 
 * @version 1, June 21, 2002 
 */
function isDatasource(nameToCheck) {
    //grab the datasourceService object
    var dsObj = createObject("Java","coldfusion.server.ServiceFactory");
    //check if the name is one of the datasources
    return structKeyExists(dsObj.datasourceService.getDatasources(),nameToCheck);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson