These are CF 5 solutions.

Try the undocumented <CFIF CF_IsColdFusionDataSource("MyDSN")> or if you prefer a 
supported option you could try something like this:

<CFSET DSN = "Foo">
<CFSET DSNType = "ODBC">

<CFTRY>
        <!--- Query should always fail and go to CFCATCH --->
        <CFQUERY NAME="Test" DATASOURCE="#DSN#" MAXROWS="1" DBTYPE="#DSNType#">
                SELECT Foo FROM Bar
        </CFQUERY>
        <!--- Just in case --->
        DSN exists
        <CFCATCH TYPE="Any">
                <CFIF FindNoCase("Data source not found",CFCATCH.Message)>
                        DSN does not exist!
                <CFELSE>
                        DSN exists
                </CFIF>
        </CFCATCH>
</CFTRY>


Chris


> -----Original Message-----
> From: Stan Winchester [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 27, 2003 1:55 PM
> To: CF-Talk
> Subject: Is there a way to test to see if a data source exists?
> 
> 
> Is there a way to test to see if a data source exists? I am 
> creating a setup
> routine where the user will enter the data source name, and I 
> would like to
> check to see if it exists before using it.
> 
> Stan Winchester
> [EMAIL PROTECTED]
> http://www.aftershockweb.com/
> Tel. 503-244-3440
> Fax 503-244-3454
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to