次の例では、SQL Server データソースを追加します。
<cfscript>
// Login is always required. This example uses two lines of code.
adminObj = createObject("component","cfide.adminapi.administrator");
adminObj.login("admin");
// Instantiate the data source object.
myObj = createObject("component","cfide.adminapi.datasource");
// Create a DSN.
myObj.setMSSQL(driver="MSSQLServer",
name="northwind_MSSQL",
host = "xx.x.xxx.xx",
port = "1433",
database = "northwind",
username = "sa",
login_timeout = "29",
timeout = "23",
interval = 6,
buffer = "64000",
blob_buffer = "64000",
setStringParameterAsUnicode = "false",
description = "Northwind SQL Server",
pooling = true,
maxpooledstatements = 999,
enableMaxConnections = "true",
maxConnections = "299",
disable_clob = true,
disable_blob = true,
disable = false,
storedProc = true,
alter = false,
grant = true,
select = true,
update = true,
create = true,
delete = true,
drop = false,
revoke = false );
</cfscript>
次の例でも同じ SQL Server データソースを追加しますが、argumentCollection 属性を使用し、すべてのメソッド引数を 1 つの構造体として渡しています。
<cfscript>
// Login is always required. This example uses a single line of code.
createObject("component","cfide.adminapi.administrator").login("admin");
// Instantiate the data source object.
myObj = createObject("component","cfide.adminapi.datasource");
// Required arguments for a data source.
stDSN = structNew();
stDSN.driver = "MSSQLServer";
stDSN.name="northwind_MSSQL";
stDSN.host = "xx.x.xxx.xx";
stDSN.port = "1433";
stDSN.database = "northwind";
stDSN.username = "sa";
// Optional and advanced arguments.
stDSN.login_timeout = "29";
stDSN.timeout = "23";
stDSN.interval = 6;
stDSN.buffer = "64000";
stDSN.blob_buffer = "64000";
stDSN.setStringParameterAsUnicode = "false";
stDSN.description = "Northwind SQL Server";
stDSN.pooling = true;
stDSN.maxpooledstatements = 999;
stDSN.enableMaxConnections = "true";
stDSN.maxConnections = "299";
stDSN.enable_clob = true;
stDSN.enable_blob = true;
stDSN.disable = false;
stDSN.storedProc = true;
stDSN.alter = false;
stDSN.grant = true;
stDSN.select = true;
stDSN.update = true;
stDSN.create = true;
stDSN.delete = true;
stDSN.drop = false;
stDSN.revoke = false;
//Create a DSN.
myObj.setMSSQL(argumentCollection=stDSN);
</cfscript>
<!--- Optionally dump the stDSN structure. --->
<!---
<cfoutput>
<cfdump var="#stDSN#">
</cfoutput>
--->