Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello helpers,

I am Doing application.

I have one page on which I am collecting data from user and saving data into database.

When I click on save button all data is successfully saved but when I Refresh that Page the entries are saved twice.

How could I avoid insertion of Duplicate entries on Page Refresh.

Updated 7-Feb-11 4:35am
Rounak Hasan 12-Feb-11 5:36am    
Is the database table dont have any primary key??????

Best way would be to check if the Data is already in your database before you insert it.

Also you could set a Flag after inserting your data (for example in a sessionvariable) and check for this flag before you save (again).
Share this answer
nitin bhoyate 7-Feb-11 7:58am    
Good question! Get's my 5.

There is a solution with code here[^] - I haven't tried it, but the idea seems sound.
Share this answer
nitin bhoyate 7-Feb-11 8:02am    
Thanks Very Good Link. But According to My two hours of googling. Check IS Exist in Database will take less time(8 sec Provided in one blog, Session checking takes 11 sec provided in same blog

Well Til i am Googling to fing proper and Quick Way.
Thanks for Reply
Hi nitin bhoyate :rose:,


1. whenever u will insert the data, then you validate the input data'a. (Script via..(javascript or anything..))

2. whenever u will insert the data then, Clear the values.

Note: validation is the best solution...
Share this answer
Rounak Hasan 12-Feb-11 5:34am    
I thik it is best option..
Well, in my opinion you should only save the data when IsPostBack [^]is true.

    //save my data
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900