How can I programmatically delete a data source in ColdFusion

[SOLVED]

I have a C # program that interacts with ColdFusion by running a CFM file. One of the tasks of a CFM file is to create three data sources in ColdFusion. It works well.

The problem I'm dealing with is that I have a requirement to use the same methodology to remove the data source. According to the Adobe documentation, this function is available, but I can not find any examples of this on the WWW.

Can someone here describe how to remove a ColdFusion data source using the code in a CFM file?

Thanks in advance.

Regards, Ken.

As Alex noted, I really had to include the ColdFusion version number. Version 11.

Working permission based on Ageax answer:

<cfscript> 
adminObj = createObject("component","cfide.adminapi.administrator"); 
adminObj.login("#URL.cfpw#"); 

myObj = createObject("component","cfide.adminapi.datasource"); 

myObj.deleteDatasource("#URL.ds#");
</cfscript>

, , .

+4
1

CF Admin API. , - ColdFusion.

<cfscript>
    /* Connect to CF Admin API */
    dbConnection = CreateObject("cfide.adminapi.administrator").login("adminPW","adminUser");
    if (dbConnection) {    
        /* Instantiate datasource object */
        ds = createObject("cfide.adminapi.datasource"); 

        /* Delete the datasource */
        ds.deleteDatasource("myDatasourceName"); 
    }
</cfscript>

. CF-, , , , .

+5

Source: https://habr.com/ru/post/1694931/


All Articles