ADO for the Beginner - Connecting to a Database
(Page 2 of 5 )
Before you can work with the data inside of a database you must first connect to a database. There several ways to do this:
How to Create a DSN-free Connection
Of the two ways to connect to a database, the DNS-free way is probably the easiest. It can be used to connect to any Microsoft Access database. For our example let's say you have a database named ChuckNorrisVictims.mdb that is located on a web directory such as " c:/webinfo/ ". To connect to the ChuckNorrisVictims database, you could use the following code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open " c:/webinfo/ChuckNorrisVictims.mdb "
%>
As you can see from the above code, you must include the database driver (Microsoft.Jet) and the path to your database.
Next: Connect to a Database with ODBC >>
More ASP Articles
More By James Payne