ASP Database Fundamentals (Part 1) - Connecting To A Database
(Page 3 of 6 )
When accessing a database using ADO, the first thing you need to do is make a connection. Creating a connection to a database can sometimes be the hardest part of building an ASP application. When you create a connection object, you can reference the database one of two ways. The first way is to fully qualify the database name, the driver, and location within the connection string for the database. The second is to create a DSN (Data-source name) for the database and refer to it by name in the connection string.
For example, connecting to an access database using a fully qualified connection string may look like this:
<%
ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & "C:\database\mydb.mdb"
%>
Being that information about database driver, name, and location are specified when a DSN is created in the system control panel, you only need to specify the DSN name when utilizing it. For example, to reference a DSN called "MyDB", the connection information would look like this:
<%
ConnectionString = "DSN=MyDB"
%>
Next: Establishing The Connection >>
More ASP Articles
More By Rich Smith