Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Double inserts


Message #1 by "Jay" <jtillery@n...> on Tue, 21 Jan 2003 07:52:08
Hello Board,

I am using an HTML form to post data to my access database via odbc, but 
when a users enter contact info into my database I am getting the same 
info twice, although the user only submits once. Here is my code:


sSQL = "INSERT INTO Lead_Data (username)" & _
	  "VALUES ('" & User_Name & "')"
	  
	 Set objConn = Server.CreateObject("ADODB.Connection")
		  objConn.Open "DSN=", "", ""
		  objConn.Execute(sSql)
		  objConn.Close
	 Set objConn = Nothing	  
		 Response.Redirect("addpass.htm")

Can someone help?

Thanks!
Message #2 by "sashidhar" <sashi@a...> on Tue, 21 Jan 2003 12:57:14
this happens when users presses the "Refresh" button
to avoid double entry u have to use flag
i.e u have to make a session variable 

in first form u have to diclare
session("mydata")="notinserted"

and imediately after
insert statement u declare

session("mydata")="inserted"

and make if loop which check
_______________________________

if(session("mydata")="notinserted") then
'write ur insert statement
session("mydata")="notinserted"

end if 
_______________________________________________
hope it will help

  Return to Index