Click here to Skip to main content
16,011,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

In my asp.net project i use following code after Insert statement to avoid the problem of re insertion of values to DB while refreshing the page
C#
Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);


is there any other method , because this method is not suitable in some pages.
Posted

 
Share this answer
 
v2
Comments
thatraja 13-Dec-13 8:10am    
Too much sugar is not good. Next time don't.
5!
Tom Marvolo Riddle 13-Dec-13 8:16am    
Ok i got it and Thank you very much
Praveen_P 14-Dec-13 0:31am    
thanks a lot, its working perfectly
Tom Marvolo Riddle 14-Dec-13 0:56am    
You are welcome
Hi Praveen,

If you want to do it in asp.net then you can refer here[^]
If you want to check it in DB side then you can use EXISTS function like this
SQL
IF NOT EXISTS(SELECT ID FROM InsertTableName WHERE ID = 'ID you want to insert')
BEGIN
INSERT INTO InsertTableName VALUES(101,'Name');
ELSE
Print 'Record already exist'


Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
thatraja 13-Dec-13 8:12am    
Agree this alternative but OP should implement this with solution 1, that way could reduce headaches.
5!

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