$= SetOption("WrapAtEol", "On")
; #### Set Variables ####
$DBPath = "@scriptdir\ActinicCatalog.mdb"
$CNstring = "provider=microsoft.jet.oledb.4.0;data source=$DBpath;persist security info=false"
$CMDtxt = 'SELECT "Email Address" FROM Person'
; #### Create ADO Objects ####
$cn = CreateObject ("ADODB.Connection")
? "ADO Conn ERROR @ERROR - @SERROR"
$cmd = CreateObject ("ADODB.Command")
? "ADO Cmd ERROR @ERROR - @SERROR"
$rs = CreateObject ("ADODB.RecordSet")
? "ADO RS ERROR @ERROR - @SERROR"
; #### Open Database connection ####
$cn.connectionstring = $CNstring
? "ADO CN String ERROR @ERROR - @SERROR"
$cn.Open
? "ADO CN Open ERROR @ERROR - @SERROR"
; #### Set Active commands ####
$cmd.activeconnection = $cn
? "ADO ActConn ERROR @ERROR - @SERROR"
;$rs.activecommand = $cmd Is this needed? It errors if left in!
;? "ADO ActCmd ERROR @ERROR - @SERROR"
; #### Open Recordset and Populate with results of Query ####
$cmd.commandtext = $CMDtxt $rs.Open ($cmd)
? "ADO Query ERROR @ERROR - @SERROR"
; #### Move to the first record ####
$rs.Movefirst()
? "ADO Movefirst ERROR @ERROR - @SERROR"
? ""
; #### Read all data in the recordset ####
$L=0
$Field = $rs.Fields.count -1
do
for $i=0 to $Field ; count through each column
$rs.Fields.item($i).Value ; spit out the value in that column
if $i<>$Field ", " endif ; comma separate fields
$L = $L +1
? "Number of times rs.Fields.Item(i).Value has been called:" $L
next
$rs.MoveNext() ; goto the next record
? "ADO Movenext ERROR @ERROR - @SERROR"
? ; CRLF separate records
until $rs.EOF ; until we reach the End Of the file