Question: For some reason when the user click on the submit button and he re-fresh the page the same data get's uploaded again to my SQL Server 2005 database. I do not what this to happen........... Why is this happening? I am making use of a SQL Data Source!!

My code

```
 Try

        'See if user typed the correct code.
        If Me.txtSecurity.Text = Session("Captcha") Then

            If Session("NotifyMe") = "Yes" Then
                SendEmailNS()
            End If

            RaterRate.Insert()
            RaterRate.Update()

            DisableItems()

            lblResultNS.Text = "Thank you for leaving a comment"

            LoadCompanyList()
            LoadRateRecords()

            txtCommentNS.Text = ""
            txtSecurity.Text = ""
            lblResultNS.Focus()

        Else

            Session("Captcha") = GenerateCAPTCHACode()
            txtSecurity.Text = ""
            txtSecurity.Focus()
            Validator10.Validate()

        End If

    Catch ex As Exception

        lblResultNS.Visible = True     
        lblResultNS.Text = ex.Message.ToString
        lblResultNS.Focus()

    End Try

```

Answer: 
When user visiting your page, generating new captcha. after when post or else, its checking captcha but not generating new. Move 'captcha set' code to outer scope.

```
If Me.txtSecurity.Text = Session("Captcha") Then
    ...
Else
    ...
End If

Session("Captcha") = GenerateCAPTCHACode()

```
This is happening because of the nature of WebForms relying on the PostBack model. Every time you click on a button the single form you have inside the page is posted to the server along with the viewstate. When you press F5 you normally get a warning that the form will be reposted and if you click Yes the same action is executed on the server. One way to avoid this is to perform a redirect after you save to the database:

```
Response.Redirect("~/success.aspx");

```