Applyconnection(), The generated include file, Asp javascript – Adobe Dreamweaver API Reference CS5 User Manual
Page 88

83
DREAMWEAVER API REFERENCE
The database connectivity API
Last updated 8/27/2013
applyConnection()
Availability
Dreamweaver UltraDev 4.
Description
Dreamweaver calls this function when the user clicks OK in the connection dialog box. The
applyConnection()
function generates the HTML source for a connection. Dreamweaver writes the HTML to the
Configuration/Connections/connection-name.ext include file, where connection-name is the name of your connection
(see “
” on page 79), and .ext is the default extension that is associated with the server
model.
Arguments
None.
Returns
The HTML source for a connection. Dreamweaver also closes the connection dialog box. If a field validation error
occurs,
applyConnection()
displays an error message and returns an empty string to indicate that the dialog box
should remain open.
The generated include file
The include file that
applyConnection()
generates declares all the properties of a connection. The filename for the
include file is the connection name. It has the filename extension that is defined for the server model associated with
the current site.
Note: Connections are shared, so set the
allowMultiple value
to
false
. It ensures that the connection file is included
in the document only once. It also ensures that the server script remains in the page if any other server behaviors use it.
You can see some sample include files that
applyConnection()
generates for various default server models illustrated
in the coming sections.
Note: To create a connection include file format, define a new EDML mapping file, which is like
connection_includefile.edml, as shown in “
The definition file for your connection type
84.
ASP JavaScript
The ASP and JavaScript include file should be named MyConnection1.asp, where MyConnection1 is the name of the
connection. The following sample is an include file for an ADO connection string:
<%
// Filename="Connection_ado_conn_string.htm"
// Type="ADO"
// HTTP="true"
// Catalog=""
// Schema=""
var MM_MyConnection1_STRING = "dsn=pubs";
%>
The server behavior file includes this connection by using the relative file include statement, as shown in the following
example: