This example script shows you how to get started in web/database development by connecting an HTML page to an MS Access database via VbScript.
<SCRIPT LANGUAGE="VBScript">
Dim objConn
Dim objRec
Dim strConnect
Dim Query
' Put an SQL query into a string
Query = "select * from orders;"
' Access file must reside locally. A URL won't work
strConnect = "C:/My Documents/NorthWind.mdb"
' We access the database thru an ADO connection
Set objConn = CreateObject ("ADODB.connection")
' This tells which provider / driver to use
objConn.Provider="Microsoft.Jet.OLEDB.4.0"
' Opens the database connection
objConn.Open strConnect
' Creates a recordset to hold the data coming back from the query
Set objRec = CreateObject ("ADODB.Recordset")
' Causes the query to execute
objRec.Open Query, objConn
' Output each record
do while not objRec.EOF
document.write (objRec.Fields(0).Value)
document.write (" --->> ")
document.write (objRec.Fields(1).Value)
document.write ("<br />")
objRec.MoveNext
loop
' Close the recordset
objRec.close
set objRec = nothing
' Close the database connection
objConn.close
set objConn = nothing
</script>