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

Access mass update

Status
Not open for further replies.

cumap

IS-IT--Management
Joined
Jul 9, 2007
Messages
268
Location
US
Hi all,
I'm trying to get this mass update ASP code to work for an Access database, but everytime I hit update, it just return the same original values... unlike it worked with the MS SQL database I worked with before. I wonder that there could be something different between SQL and Access causing it... Could someone please tell!!!
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()
 
Try this little edit:

Code:
rs.Open "SELECT tempName,tempSelected FROM Templates WHERE idTemplate = " & cint(strID), objConn
[red]rs.edit[/red]
    if len(tname)>0 then

JB
 
rs.edit"

You would think so, but edit is not a property in an ADO recordset.

I think it would be best to post in forum333
 
I'm sorry guys who actually wasting their time to reply to this message due to the fact that I was so stupid to realize I copied and pasted the whole code from another project without noticing there is a included file which called a database that is not belong to this particular project. After re-called the right file at the right location, the problem fixed but does not erase the fact that I am a dumb A.

Anyway, thanks and sorry all!!! :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top