Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desparate - Database Update!!

Status
Not open for further replies.

slechols

Programmer
Nov 28, 2001
28
0
0
US
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(&quot;Last_Update&quot;)) then
if audit_udo = &quot;&quot; then
objRS5.fields(&quot;Audit_UDO&quot;) = 0
elseif Isnumeric(audit_udo) then
objRS5.fields(&quot;Audit_UDO&quot;) = audit_udo
else
objRS5.fields(&quot;Audit_UDO&quot;) = 0
end if

if assets_udo = &quot;&quot; then
objRS5.fields(&quot;Assets_UDO&quot;) = 0
elseif Isnumeric(assets_udo ) then
objRS5.fields(&quot;Assets_UDO&quot;) = assets_udo
else
objRS5.fields(&quot;Assets_UDO&quot;) = 0
end if

if term_udo = &quot;&quot; then
objRS5.fields(&quot;Term_UDO&quot;) = 0
elseif Isnumeric(term_udo) then
objRS5.fields(&quot;Term_UDO&quot;) = term_udo
else
objRS5.fields(&quot;Term_UDO&quot;) = 0
end if
end if

j = j + 1
objRS5.movenext
loop

objRS5.UpdateBatch adAffectAll
objRS5.Requery
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top