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!

problem updating to database??? Please help

Status
Not open for further replies.

cat5ive

MIS
Dec 3, 2004
184
US
Hi,

I have an asp page (Page2) that display a table of records, invoice#. When user clicks submit then Page2 submits itself and update those invoice# by putting time stamp to database file. When finish updating, it redirect to the input page (Page1). Sometime it work fine but sometime user claims that she click submit later on found out that those invoices did not get stampped.
She did not see any differences whether the update was success or not. It's always took her back to the page1 like it suppose to. Reason that she knows some of the batch fail because she were able to pull those data again.
The way she pull data to this page is by batch#. When it has a problem, the whole batch did not get stampped.

For example she enter batch# AAA, the asp display as below
----------------------------------------
Invoice#
123
222
333
444
Submit
-----------------------------------------
When I ask her to try again then it work fine.
She have to do this same job everyday, submit each batch of invoices, couple batches a day. Someday all the batches got stampped. Someday 1 or 2 batches did not get stampped.
Below is my code that do the update. Can anyone see if anything wrong with my code. Or what other possibility that could cause the problem. I don't think user forget to process some of them. She said she wrote down each batch# that she process.
By the way, I think I don't need the code in red. Can I take them out?
Thank you in advance for any help.
Code:
if strflag > ""  then  'strflag = 1 = after submit itself
    
   // build odbc
    
   set objconn= server.createobject("adodb.connection")
   objconn.open "DSN=as400DSN; database=172.16.1.10; uid=NO; pwd=XXXX; " 
   [COLOR=red]
   set rsMVAPH=server.CreateObject("ADODB.recordset") [/color] 
   
   // Output to Invoice Payable Header 
   
   for idx = 1 to request.form("invnumber").count
	  apprinv = "apprinv" & idx-1
	  varapprinv = request(apprinv)
	  
	  if varapprinv = "on" then
        strinvnumber = request.form("invnumber")(idx)	 
        strpaynumber = request("bankid")(idx) + mid(sysDate,3,6)
		
        sqll = "update cisdtalib.$mvaph" 
	    sqll = sqll & " set phapvu= '"& username&"' , phapvd= '"&sysdate&"', phpmt#= '"&strpaynumber&"' , phstag = '"&strinvflag&"'"	 
        sqll = sqll & " where phinv#= '"&strinvnumber&"'"	 
      
        objconn.execute(sqll)   
	  end if  
    next   
   [COLOR=red]
   set rsMVAPH=nothing[/color]
   objconn.close
   set objconn = nothing   
   
   newurl = "mv_payapprove.asp"
   Response.redirect newurl      
     
 end if     ' strflag = 1

Code:
<form action="page2.asp?flag=1" method="post" name="f1">
 
Yes you can get rid of the recordset object since you are just using the Execute method of the connection object and the only thing you are executing is an update statement... and the update statement doesnt return any resultset.

As for the error, perhaps if there is an on error resume next statement in the code you could comment that out to help find the problem.

Also you can add some debug code like this:[tt]
IF objconn.Errors.Count > 0 THEN
Response.Write "oh no! an error! call cat5ive!"
Response.End
END IF[/tt]

This is perhaps difficult to give an easy debug answer because it is usually not considered an error when zero rows are affected when executing a SQL UPDATE statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top