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

Refresh Query 2

Status
Not open for further replies.

phzero

Programmer
Joined
Feb 14, 2002
Messages
86
Location
ZA
Hi All,

I'm using VBScript and SQL Server 7.0. I have a Submit button on my form in my ASP page, which, once clicked, will update my SQL Database on my Web Server with some information on the form. However, after the action has been performed and I click the Refresh button on my Browser, it updates my database again. Does anyone know what I should be checking for or whether I'm doing something wrong. How can I prevent this from happening.
Any comments are welcome.
Thanks a stack.
 
Hallo,

I'm no expert, but I think this is a common problem.
I think the way around it is to somehow identify the update you are doing, then store somewhere the fact that you've done it, and if you get the same transaction again then ignore it.

Sorry if that's a bit waffly.

If there's only one user you can use an Application variable to keep a 'lngLastUpdateNumber'. You can then give each transaction a number in ascending order in which they happen. Then only do the SQL update if the transaction number > lngLastUpdateNumber. If you do the transaction, then update lngLastUpdateNumber.

I guess whether this is of any use will depend on your application structure. There may well be 101 reasons why my theory is flawed and would not work, but I think it's a start.

If you get something working would you report back to this thread, please?

- Frink
 
Your theory has crossed my mind, but I don't wanna query the database again as it will slow down my performance and creating temporary variables uses more resources. Thanks for the feedback anyway. I was just completing an online Mircosoft survey. When I came to the end, the normal "Thank You" screen comes up. I then clicked the Refresh button and I was prompted, by way of a message box, to Resend the information or Cancel. If I could get that kind of thing going, it'll be first prize. However, I'll let you know how I fared.
 
The prompt to resend the information is automatic. If you POST the data from a form to your page which performs the update, you will get this message if you try and refresh. If you pass the information in a querystring, you won't and it will automatically perform the update again.

A way to stop this happening is to have one page which only performs the update and, once finished, redirects to another page (either back to the input page or maybe to a confirmation page). That way the user never stops on the update page and so can't refresh it.

An outline of this idea is below:

input.asp
This contains your form which POSTs the data to the next page.

insert.asp
This opens a connection to the database, builds the SQL insert string and executes it. It then uses
Code:
Response.Redirect("confirm.asp")
to automatically go to the confirmation page.

confirm.asp
Just displays a confirmation message that record has been inserted. --James
 
Well Frink, there you have it as well. Many thanks to you, James, for posting this helpful information and as a token of my gratitude, I'm giving you two stars for your efforts. Thanks again, it is much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top