Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:40:58+00:00 2026-06-12T09:40:58+00:00

Hello there im having problem whenever i press the refresh button it keeps adding

  • 0

Hello there im having problem whenever i press the refresh button it keeps adding :/ how do i prevent it? its been my day 2 figuring this out and i failed 🙁

protected void Button1_Click(object sender, EventArgs e)
        {
            //Instantiate the connection with the database 
            using (SqlConnection myConnection = new SqlConnection("user id=username;" +
                                                                  "password=password;" +
                                                                  "trusted_connection=yes;" +
                                                                  "database=DataBaseConnection;" +
                                                                  "connection timeout=30;"))
            {
                //Open the Connection object
                myConnection.Open();

                //Instantiate a SQL Command with an INSERT query
                SqlCommand myCommand = new SqlCommand("INSERT INTO BasicInfo (Firstname,Surname) Values(@a,@b);", myConnection);

                if (TextBox1.Text !=null && TextBox2.Text != null)
                {
                    //Texbox 
                    myCommand.Parameters.AddWithValue("@a", TextBox1.Text);
                    myCommand.Parameters.AddWithValue("@b", TextBox2.Text);

                    //Execute the query
                    myCommand.ExecuteNonQuery();
                }
                else
                {
                    //Code HEre?
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:40:59+00:00Added an answer on June 12, 2026 at 9:40 am

    One way to handle this problem is to do a Response.Redirect at the end of the Button1_Click event back to original page. The Response.Redirect will make the browser do a GET request for the page, so if the user hits F5 they’ll just redo the GET (and not POST the form again).

    This approach is sometimes called the Post/Redirect/Get pattern. This blog post has a pretty good writeup of the approach:
    http://blog.andreloker.de/post/2008/06/Post-Redirect-Get.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello there i'm having a problem here i have an add and edit form
Hello guys i've been having a problem with Mathematica 8.0. When i export my
. Hello, I'm using jqueryui's datepicker, and it works great but there's a problem.
Hello ladies and gents, I'm having a bit of problem with accept() . I
Hello i am having a problem in setting the image in relative layout.The problem
After having solved the problem of getting the editor to launch when there's a
Hello there Stack Overflow, I hope you'll help me with my very first question
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
Hello is there a class that does a pretty conversion?
hello i would like to know if there is any dll or global hook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.