Q. How can I connect to a Microsoft Office Access database from a VBScript?
A. You can connect to an Access database by using the standard ADO database (ADODB) object. For example, to connect to Access file d:\ntfaq files\faq.mdb, use the following code (notice that we use the Microsoft.Jet.OLEDB.4.0 provider):
Set conn = CreateObject("ADODB.Connection") ' Connect to the database strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\NTFAQ Files\faq.mdb" conn.Open strConnect Once connected, you can execute commands against the database. For example, to read the highest article number from a database named Saville_FAQ, use this code: StrSQL = "Select max(ArticleID) from Saville_FAQ" Set rs = conn.Execute(StrSQL) Do While not rs.EOF wscript.echo "The information is " & RS(0) intFAQNumber = RS(0) rs.MoveNext Loop