p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: Clicking refresh button on browser will i nsert the same reco rd again


Message #1 by "Matt Riemann" <mriemann@b...> on Mon, 3 Mar 2003 11:13:39 -0800
Have you tried clearing the buffer after you add the record.

Response.buffer =3D true
Response.clear
Response.redirect request("script_name")



-----Original Message-----
From: Gillian Harber [mailto:gillian@m...]
Sent: Thursday, February 27, 2003 6:17 AM
To: ASP Databases
Subject: [asp_databases] Re: Clicking refresh button on browser will i
nsert the same reco rd again

I have a suggestion.  It has sort of already been suggested, but not in
the
way I'm going to suggest exactly.

Have your page with your form on it.  This page gets submitted to an
entirely different page, this page collects the request.form data and
does
whatever your page would orginally have done.  At the end of the page
that
is receiving the data you have a response.redirect back to the page with
the
form on.  Now the important bit, make sure the page you submit to (the
one
collecting the data) has no html on it.  The page you sumbitted the data
to
will never reach the browser, hence clicking back only goes back to the
page
with the form on (although you will be already on this page after the
redirect from the receiving data page).  Clicking refresh will only
refresh
the page since the page does not still have the form post data.

Hope that helps.

Gillian


----- Original Message -----
From: <Colin.Montgomery@C...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, February 27, 2003 12:15 PM
Subject: [asp_databases] Re: Clicking refresh button on browser will i
nsert
the same reco rd again


> you're absolutely right Paul - flawed logic on my part.  I am
interested
to
> find out how this could be accomplished, so i'll keep thinking about
it
and
> post any ideas I have.  If you do figure it out, it would be good if
you
> could post your solution.
>
> Cheers,
> Col
>
> -----Original Message-----
> From: paul murphy [mailto:paulmcn01@y...]
> Sent: 26 February 2003 21:42
> To: ASP Databases
> Subject: [asp_databases] Re: Clicking refresh button on browser will i
> nsert the same record again
>
>
> thanks for replying colin,
> I'll run through anexample of your explanation just to make sure I got
u
> correct and then I'll show you how I'll still have problems!
> 1.I insert a record into the field and the autonumber of this field
will
> increment automatically when I insert the record(ie I don't have to
pass
> this value in my INSERT statement).
> 2. I then  grab this autonumber field for the record I just entered
from
> the database and store it in the session variable.
> 3. The user is back to the page from where they entered the values
just
> previously. They then hit refresh on the browser. I go to check my
session
> variable and see if it corresponds to the number of the record that
was
> just entered. It was so the user can't enter record...
>
> But the user might want to enter a new record, which they can do form
this
> page. The session variable will prevent them from doing this aswell
right?
> When they try to insert a new reocrd it will check then session
variable
> against the autonumber in the database and prevent the user from
inserting.
> So they will only be allowed to insert one record which I don't want!
>
> > how about setting the value of the session variable equal to the
> Keyfield of
> the record, once it's inserted?  I.e. if you're using an
> Autonumber/Identity
> field, simply insert the record, grab it's ID and write it to the
session
> variable.  THis way, before you do each insert you can check if the
record
> exists already and alert the user as opposed to inserting a duplicate.
>
> Would this work?
>
> HTH,
> Col
>
>
>
> *******
>
> This message and any attachment are confidential and may be privileged
or
otherwise protected from disclosure.  If you are not the intended
recipient,
please telephone or email the sender and delete this message and any
attachment from your system.  If you are not the intended recipient you
must
not copy this message or attachment or disclose the contents to any
other
person.
>
> For further information about Clifford Chance please see our website
at
http://www.cliffordchance.com or refer to any Clifford Chance office.
>
>
>



  Return to Index