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 7965903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:16:40+00:00 2026-06-04T06:16:40+00:00

I am attempting to create a web form where data from several text box’s

  • 0

I am attempting to create a web form where data from several text box’s will enter data into a n SQL database I have created. My code is listed below, and the problem is that when it compiles, it acts as if it hasn’t. The messagedisplay.text does not change, and the SQL database does not update. Does anyone know a solution?

protected void createButton_Click(object sender, EventArgs e)
    {
        string state = stateTextBox.Text;
        string country = countryTextBox.Text;
        string lake = lakeTextBox.Text;



         SqlConnection connection = new SqlConnection("Data Source=.MetricSample;Initial Catalog=ElementID;"+ "Integrated Security=true;");

         connection.Open();
            try
            {
                using (SqlCommand command = new SqlCommand(
                    "INSERT INTO ResearcherID VALUES(@ResearcherFname, @ResearcherLName)", connection))
                {
                    command.Parameters.Add(new SqlParameter("ResearcherFName", country));
                    command.Parameters.Add(new SqlParameter("ResearcherLName", state));
                    command.ExecuteNonQuery();
                }
                messageDisplay.Text = "DB Connection Successfull";
            }
            catch
            {
               messageDisplay.Text = "DB Connection Failed";
            }




    }
  • 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-04T06:16:41+00:00Added an answer on June 4, 2026 at 6:16 am

    try this

    using (SqlCommand sqlCmd = new SqlCommand("INSERT INTO ResearcherID (FieldNameForFirstName, FieldNameForLastName) VALUES (@ResearcherFname, @ResearcherLName)", sqlConn)) {                  
    
                sqlCmd.Parameters.AddWithValue("@ResearcherFname", country);  
                sqlCmd.Parameters.AddWithValue("@ResearcherLName", state);  
           }
    

    Also use connection.Open(); inside try

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

Sidebar

Related Questions

I'm attempting to create a DataGrid with some data retrieved from a Web Service.
I am attempting to create a web page that will allow a user to
I'm attempting to create Data Access Layer for my web application. Currently, all datatables
I'm attempting to create a web application with TweetSharp that will connect to Twitter
I'm attempting to create a web app that works with business data models, pretty
I'm attempting to create a custom control that inherits from System.Web.UI.WebControls.ListView . Codebehind: using
I'm trying to export data from a web app into excel, but there is
I am attempting to create functionality in a JSF1.2/ADF web app that will periodically
I'm attempting to create a process that verifies data within a database and notifies
I am attempting to create a Stored Procedure for a newly created database. However

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.