Now that you have a machine on which to practice, the first thing that is required for you to start using a database with your ASP pages is a connection. Using your editor of choice(Visual Interdev 6.0 is very nice because it has Intellisense, which will help you see the methods and properties of the various ADO objects), write the following code:
Session("DB_ConnectionString") = _
"DSN=myDSN;UID=myUID;PWD=myPWD;DB=myDB;HOST=myHOST;SERV=MyService;SRVR=MyServer;PRO=MyProtocol;"
Dim objConnect 'Declare the connection variable
'Set up Connection Object
Set objConnect = Server.CreateObject("ADODB.Connection")
objConnect.Open Session("DB_ConnectionString")
Notice that I'm using a Session variable for the connection string. This is useful if you plan on using the same database for multiple ASP pages, which is often the case. If you are using Visual Interdev, you can use the data connection wizard to create this Session variable for you. In VI 1.0, you do this by clicking on Project - Add to Project - Data Connection. If you do not already have a DSN, this will also let you create one. MAKE SURE YOU USE A SYSTEM DSN! If you use a File DSN, then the default web user account on Windows NT (IUSR_MACHINENAME) will not be able to access the database. Also note that many of the parameters in the connection string above are not necessary if you are using a database on the same machine as your server. In fact, you do not even need to use a DSN. An alternative, if you have the database as a file on your web server, is to do the following:
Dim objConnect 'Declare the connection variable
Dim cnpath 'Connection path to database file
'Set up Connection Object
Set objConnect = Server.CreateObject("ADODB.Connection")
cnpath="DBQ=" & server.mappath("/path/database.mdb")
objConnect.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath
This assumes that the database is located within your web directory, in the subdirectory "path". You can set cnpath to "C:\path\database.mdb" if you want it to use any path on your machine. Once you have established a connection, you are ready to move on to recordset and command objects.
Also note that you could (and should) use an Application variable instead of a Session variable, assuming everybody on your site will be connecting to the same database, which is typically the case. Finally, it is very important that you only open connections when you need them, and that you keep them open as briefly as possible. As soon as you're finished with them, call Connection.Close.