I need to do a batch update on a database, but I can't figure out how to do it. I am pulling multiple records from the database according to a specific string, but I want to do a batch update on those records according to a key field in the query. Here is my script (I am pulling according to Test.EIID and want to update according to Test.Key): (this query pulls 16 records)
set objRS5=Server.CreateObject("ADODB.Recordset"
strsql="SELECT test.EIID, test.KEY, test.Term_UDO, test.Assets_UDO, test.Audit_UDO, Last_Update FROM test WHERE Test.EIID = '6130013610655EW' ;"
objRS5.Open strsql, strconn, adOpenStatic, adLockBatchOptimistic
i = CInt(Session("Index")
j=1
do while j < i+1
If isNull (objRS5("Last_Update") then
if audit_udo = "" then
objRS5.fields("Audit_UDO" = 0
elseif Isnumeric(audit_udo) then
objRS5.fields("Audit_UDO" = audit_udo
else
objRS5.fields("Audit_UDO" = 0
end if
if assets_udo = "" then
objRS5.fields("Assets_UDO" = 0
elseif Isnumeric(assets_udo ) then
objRS5.fields("Assets_UDO" = assets_udo
else
objRS5.fields("Assets_UDO" = 0
end if
if term_udo = "" then
objRS5.fields("Term_UDO" = 0
elseif Isnumeric(term_udo) then
objRS5.fields("Term_UDO" = term_udo
else
objRS5.fields("Term_UDO" = 0
end if
end if
j = j + 1
objRS5.movenext
loop
objRS5.UpdateBatch adAffectAll
objRS5.Requery
%>
set objRS5=Server.CreateObject("ADODB.Recordset"
strsql="SELECT test.EIID, test.KEY, test.Term_UDO, test.Assets_UDO, test.Audit_UDO, Last_Update FROM test WHERE Test.EIID = '6130013610655EW' ;"
objRS5.Open strsql, strconn, adOpenStatic, adLockBatchOptimistic
i = CInt(Session("Index")
j=1
do while j < i+1
If isNull (objRS5("Last_Update") then
if audit_udo = "" then
objRS5.fields("Audit_UDO" = 0
elseif Isnumeric(audit_udo) then
objRS5.fields("Audit_UDO" = audit_udo
else
objRS5.fields("Audit_UDO" = 0
end if
if assets_udo = "" then
objRS5.fields("Assets_UDO" = 0
elseif Isnumeric(assets_udo ) then
objRS5.fields("Assets_UDO" = assets_udo
else
objRS5.fields("Assets_UDO" = 0
end if
if term_udo = "" then
objRS5.fields("Term_UDO" = 0
elseif Isnumeric(term_udo) then
objRS5.fields("Term_UDO" = term_udo
else
objRS5.fields("Term_UDO" = 0
end if
end if
j = j + 1
objRS5.movenext
loop
objRS5.UpdateBatch adAffectAll
objRS5.Requery
%>