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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mass update

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
Hello all,
I was told to post this question in this forum instead hopefully that someone can see the reason why the code does not update nor save data when called.

Code:
'declare the variables
Response.Buffer = true

On Error Resume Next

        
Dim strErrorMessage
Dim bolErrors

'Initialize variables
strErrorMessage = ""    'The error messages for tech. support
bolErrors = False        'Have we found any errors yet?

'Now our two subs
sub TrapError(strError)
    bolErrors = True    'we've found an error!
    strErrorMessage = strErrorMessage & strError & ", "
end sub

'first, get the total # of items that could be updated
Dim icount
icount = request.form("count")

'variables: id, name, selected template
Dim tid,tname,tselect
Dim iLoop, iString, arrCols

'get current page
pCurPage = Request.form("curPage")
For iLoop = 0 to icount
    tname   = Request.form(iLoop & ".tempName")
    tselect = Request.form("tempSelected")
    sDelete = Request.form(iLoop & ".delete")
'    if NOT numberValidation(sDelete) then
'        response.Redirect "error.asp?msg=" & Server.URLEncode("Invalid ID to delete!")
'    end if
    strID     = Request.form(iLoop & ".idTemplate")
'    if NOT numberValidation(strID) then
'        response.Redirect "error.asp?msg=" & Server.URLEncode("Invalid ID to update!")
'    end if

    'update the appropriate column
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.CursorType     = 2
    rs.LockType        = 3
    rs.Open "SELECT tempName,tempSelected FROM Templates WHERE idTemplate = " & cint(strID), objConn

    if len(tname)>0 then
        rs.Fields("tempName") = lcase(tname)
    end if
    if len(tselect)>0 then    
        rs.Fields("tempSelected") = tselect
    end if
    
    rs.Update
    
    if len(sDelete) > 0 then
        'Delete records from ProductSupport
        strSQL = "DELETE FROM Templates " _
               & "    WHERE idTemplate = " &  trim(sDelete)
        objConn.Execute strSQL
    end if
    
    If Err.number <> 0 then
        TrapError Err.description
    End If
    
Next
call closeRS(rs)
call closedb()

Thanks!
 
I'm very sorry wasting anyone time since this is MUCH my stupid fault. I seem to call the wrong INCLUDED database when I copy this code from another website I worked with before. I guess I deserve wearing a big LOSER hat, don't you think.

anyway, it seems to work after I re-called the right db file now.

Thanks again for anyone who might accidentally read this message. :)
 
Isn't it always like that? The mere act of posting seems to fix a lot of things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top