Invoking database drivers
An application must invoke a database driver to establish two-way communications with a database. A Web application invokes a driver by using a connection string. A connection string consists of all the information (or "parameters") required to establish a connection to a database. In its simplest form, a connection string specifies a driver and a database. Example:
Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\Inetpub\wwwroot\Scaal\scaalcoffee.mdb
ASP connection strings can contain a "Provider" parameter specifying an OLE-DB driver. If you omit this parameter, by default ASP uses the OLE-DB provider for ODBC drivers. In the above example, the OLE-DB driver for ODBC drivers would communicate with the ODBC driver, Microsoft Access Driver, which in turn would communicate with the Access database, scaalcoffee, mdb.
The parameters in a connection string may vary depending on the driver. Here's a connection string for a SQL Server database called UnsolvedCases located on a server named Hoover:
Driver={SQL Server};Server=Hoover;Database=UnsolvedCases;UID=DanaS;PWD=Queequeg
Note: UID stands for user ID; PWD for password.
UltraDev simplifies the process of inserting connection strings into your pages. When you choose a connection type in the Define Connection dialog box, the appropriate text boxes appear. For example, here's how the Define Connection dialog box looks when you select JDBC as your connection type:
Here's what the same dialog box looks like when you choose the ColdFusion connection type:
Complete the text boxes and UltraDev takes care of inserting the connection string into your page. For example, if you specify an ADO connection with a DSN called SimpleSearch in the Run-Time tab, UltraDev will insert something like the following highlighted lines in your HTML code:
Note: DSN's are covered in the next section, Using a DSN in a connection string
Of course, UltraDev gives you the option of writing your own connection strings, as in the following example:
For advanced users, another option is to enter the connection string directly into the code using the HTML Source inspector (Window > HTML Source) or any other text editor.
|