ONE Active Server Pages Product Home Page Developer Site Version


Using DSN-less Connection Strings

As discussed in Creating Connection Strings, using a DSN-less connection is one way to specify the information (in the form of parameters and their values) that is needed to establish a database connection. Unlike system DSNs and file DSNs, which incorporate this information by reference, DSN-less connection strings include all required database parameters.

You use the following syntax for a connection string:

connect_string = "[parameter_1=value_1; parameter_2=value_2; parameter_3=value_3]"

where [parameter_1=value1; parameter_2=value_2; parameter_3=value_3] specifies the required parameters for the given database.

The following example shows a DSN-less connection string for a MySQL database:

connect_string = "Driver={Mysql}; Server=[server_name];
Port=[port_number]; Database=[database_name];
UID=[username]; PWD=[password]"

where [server_name] is the name of the database server, [port_number] is the port for the database server, [database_name] is the name of the database, and [username] and [password] are the username and password required for accessing the database.

Different types of databases can require that you specify different parameters. The parameters to configure for each database in DSN-less connection strings are provided in Syntax for DSN-less Connection Strings.

Connection strings must be constructed according to the requirements of the ODBC driver being used. Sun ONE ASP for Windows uses standard Windows ODBC drivers, so connection strings you developed for Windows will work. However, the ODBC drivers for UNIX and Linux platforms are different than for Windows, so before you can use Windows connection strings with Sun ONE ASP for UNIX or Linux, you may need to edit them to use the syntax described in this section.

With Sun ONE ASP for UNIX or Linux you cannot use DSN-less connection strings or file DSNs for connecting to Microsoft Access or Microsoft SQL Server 6.5 databases; you must use system DSNs for connecting to these databases.

Note icon Note On UNIX and Linux systems, Sun ONE ASP installs the ODBC drivers to support a number of databases. However, it does not support all databases on all platforms. To see the list of installed drivers for your platform, see Supported in This Release.

In this section:

Syntax for DSN-less Connection Strings

See also:

Connecting to a Database

Creating Connection Strings