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

  • SEARCH
  • Home
  • 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 7923473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:20:20+00:00 2026-06-03T17:20:20+00:00

I am trying to submit filledin information in the form to the database. I

  • 0

I am trying to submit filledin information in the form to the database. I have done the below mentioned coding for the save button. When I click on the save button to save the information, I am getting an error. I need it to be done and for the same need help from the geeks around here.

COde for SAVE button data from database

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

        string conn = ConfigurationManager
                       .ConnectionString("welcome").ConnectionString;
        SqlConnection con=new SqlConnection(conn);
        SqlCommand cmd = new SqlCommand("Insert into abhishek(pr_name,Add,add2) values(@ah,@Ap,@qe)",con);

        cmd.CommandType = CommandType.Text;

        cmd.Parameter.Addwithvalue("@ah", TextBox1.Text.Trim());
        cmd.Parameter.Addwithvalue("@ap", TextBox2.Text.Trim());
        cmd.Parameter.Addwithvalue("@qe", TextBox3.Text.Trim());
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
}

Check the error in the image below:

enter image description 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-03T17:20:22+00:00Added an answer on June 3, 2026 at 5:20 pm

    You are missing an ‘s’ from the ConnectionStrings indexed property. Once you fix that error, however, you will also find you are missing more ‘s’ from the SqlCommand.Parameters property.

    To reveal these issues, open Properties of your code-behind file, and choose Build Action of Compile. (Also, I can see from your image that it looks like your project is setup as a Web Site rather than a Web Application; if possible, look into converting this over to a Web Application, as it offers a number of benefits.)

    Once you get your syntax corrected, then you should change your code so that the update is invoked through the button click handler, rather than on page load.

    In your markup code in the aspx:

    <asp:Button runat="server" ID="btnSave" Text="Save" OnClick="btnSave_Click" />
    

    In your code-behind:

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string conn = ConfigurationManager.ConnectionStrings["welcome"].ConnectionString;
        using (SqlConnection con = new SqlConnection(conn))
        {
            SqlCommand cmd = new SqlCommand("Insert into abhishek(pr_name,Add,add2) values(@ah,@Ap,@qe)", con);
    
            cmd.CommandType = CommandType.Text;
    
            cmd.Parameters.AddWithValue("@ah", TextBox1.Text.Trim());
            cmd.Parameters.AddWithValue("@ap", TextBox2.Text.Trim());
            cmd.Parameters.AddWithValue("@qe", TextBox3.Text.Trim());
            con.Open();
            cmd.ExecuteNonQuery();
        }
    }
    

    Note that I have moved the code into the button click event handler, and out of the Page_Load. The Load event handler should only be used for initialization items needed unconditionally on the execution path of the page (i.e., regardless of whatever button was clicked on the page), and should look something like the following:

    protected void Page_Load(object sender, EventArgs e)
    {
        // Code to run every time the page is created, both initially and on postback
    
        if (IsPostBack)
        {
            // Code to run every time the page is posted back (any submit event)
        }
        else
        {
            // Code to run on the initial creation of the page
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to submit data to a database. I have an update form
I'm trying to submit a Rails form with AJAX. I have some toggle on/off
I'm trying to check that the fields in the form below have been filled
I'm trying to submit a form with mechanize but have run into an error
I'm trying to submit a form without a submit button. This form takes values
I am trying to submit a form via JQuery Mobile. I have: <form action=#pagetwo
I'm trying to submit a form with AJAX through jQuery: $('.submit input').click(function() {return false;});
I am trying to submit my form in AJAX, so I have to serialize()
Hi I am trying to submit some information into a database using an ASP.NET
I'm trying to submit a php form to a database, but I want that

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.