Preventing Duplicate Record Insertion on Page Refresh


I was getting duplicate data in database while refreshing the page in Registration page. I searched on forum. Then i got the two type of solution

1. After  insert operation just redirect to that page

protected void BtnSubmit_Click(object sender, EventArgs e)

//code for insert

 Response.Redirect(Request.Url.ToString(), false)


2. Using sql query, before inserting into database, we have to check that record in database . If that record is available in database stop the execution of code.

For more detail,Please read this article

Posted in Errors. 7 Comments »

7 Responses to “Preventing Duplicate Record Insertion on Page Refresh”

  1. nirmal Says:

    Use indexing if you are using mysql….it works for duplicate entries….it throws an error that duplicate entry is found

    • Chandra Dev Says:

      In first method there is no relation with database.

  2. Nayan Godhani Says:


  3. viagra Says:

    I believe this is one of the so much vital information for me.

    Annd i’m happy studying your article. However should staterment
    on few basic things, The sitee styoe iis perfect, the articles is actually nice : D.
    Just right job, cheers

    • Chandra Dev Says:

      Thank you. I m glad to know.

    • Chandra Dev Says:

      Thanks. Nice to know about this.

  4. [RESOLVED]best way to maintain state when using response.redirect to same page | ASP Questions & Answers Says:

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: