' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
adCmdText = 1
adInteger = 3
adParamInput = 1
adOpenStatic = 3
adLockBatchOptimistic = 4
Set con = CreateObject("ADODB.Connection")
con.Open "Provider=SQLOLEDB;Data Source=ARNEPC4\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=Test;"
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = con
cmd.CommandType = adCmdText
cmd.CommandText = "SELECT id,val FROM data WHERE id >=?"
cmd.Parameters.Append cmd.CreateParameter("@minid", adInteger, adParamInput)
cmd.Parameters("@minid") = 2
Set rs = CreateObject("ADODB.Recordset")
rs.CursorType = adOpenStatic
rs.LockType = adLockBatchOptimistic
rs.Open cmd
Do While Not rs.EOF
    WScript.Echo rs("id") & " " & rs("val")
    rs("val") = rs("val") + 1 
    rs.MoveNext
Loop
rs.UpdateBatch
Set rs = Nothing
Set cmd = Nothing
Set con = Nothing
