% 'The first line declares the variables Dim dblocat, cnn, cnnstring, rs, SQL 'The location of our database is stored in the variable called dblocat 'Change it to the location of your database on the server. dblocat = "c:\inetpub\tutorial\data\intranet.mdb" 'These 2 lines tell the server how to connect to the database. 'cnn is used to store the 'connection object', ie how to connect to the database 'cnnstring stores the method in which the database is connected to, and takes 'dblocat (above) as the location for the database. set cnn = server.CreateObject("ADODB.Connection") cnnstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dblocat 'Now we've told it how to connect, this says to the server "Go Connect!" cnn.open(cnnstring) 'Right, we're doing well. The database is open, ready and waiting. Now, let's 'get some data out of it. These 2 lines create a 'recordset', basically letting 'you read the database. Set rs = server.CreateObject("ADODB.Recordset") rs.ActiveConnection = cnn 'Now we can query the database. The following line will do this: SQL= "SELECT * From departmental" 'The stament above should be written in the format: 'SELECT * From tablename' 'Where 'tablename' is the name of the table you created earlier in the database. rs.Open SQL 'Now, print the results on the screen. The HTML Tags, below, will put the data into a simple table. rs.MoveFirst %>
| Title | Author | Date |
| <%=rs("Title")%> | <%=rs("Author")%> | <%=rs("Date")%> | <% 'Now, move to the next record & start again. rs.MoveNext wend %>