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);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson