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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:45:40+00:00 2026-06-10T15:45:40+00:00

I am trying to learn how to take control values and insert them into

  • 0

I am trying to learn how to take control values and insert them into a db table. For example I have a textbox called NameBox. I want to grab the text from that textbox and add it into a database table.

I am not trying to do it the best way but the simplest so I can wrap by head around the concept. So far I have:

<asp:TextBox ID="NameBox" runat="server"></asp:TextBox>
<asp:TextBox ID="EmailBox" runat="server"></asp:TextBox>

Here is the code-behind.

protected void Button1_Click(object sender, EventArgs e)
{
    string name1 = NameBox.Text;
    string email1 = EmailBox.Text;

    System.Data.SqlClient.SqlConnection sqlConnection1 =
   new System.Data.SqlClient.SqlConnection(@"Data Source=E:\*********.com1.5\**********.com\App_Data\Home.sdf;");

    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
    cmd.CommandType = System.Data.CommandType.Text;
    cmd.CommandText = "INSERT INTO CustomerList (Name, Email) VALUES (" + name1 + "," + email1 + ")";
    cmd.Connection = sqlConnection1;

    sqlConnection1.Open();
    cmd.ExecuteNonQuery();
    sqlConnection1.Close();
}

Error message I am getting is

A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 – Error Locating Server/Instance
Specified)

I googled the error message and a lot of what i been reading is saying my connection is probably wrong. I tried testing this by using some of the drag and drop controls and I have a repeater working with the same connection string.

Right now I don’t even really know if this is right approach. As I am sure you can all relate at one point or another I want to see it work on a very simple level so i can start to play with it and see how it all really works.

  • 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-10T15:45:41+00:00Added an answer on June 10, 2026 at 3:45 pm

    Just copy paste the connection string you are using for the repeater code, and paste it in the Button1_Click code, where you create a new connection. There might be an extra space, or some capital letter mismatch. And for insertions, I would create a stored procedure in the database, which takes Name and Email parameters, and use the SqlCommand to execute the stored procedure.

    CREATE PROCEDURE INSERT_NAME_EMAIL_DATA
        @NAME VARCHAR(100) NULL,
        @EMAIL VARCHAR(100) NULL
    AS
    BEGIN
          INSERT INTO CustomerList (Name, Email) VALUES (@NAME, @EMAIL)
    END  
    

    And in your code you can execute the stored procedure by doing:

    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.Parameters.Add(
        new SqlParameter("@NAME", name1));
    cmd.Parameters.Add(
        new SqlParameter("@EMAIL", email1));
    cmd.Connection = sqlConnection1;
    
            sqlConnection1.Open();
            cmd.ExecuteNonQuery();
            sqlConnection1.Close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn JavaScript... I have function like, I take the format
I have been trying to learn and take advantage of WPF and databinding. I
Trying to learn about php's arrays today. I have a set of arrays like
Im trying to learn a bit about c++ and have run in to some
I'm currently trying to learn regular expressions with some simple "real world" examples. Take
I am trying to learn ASP.NET (since I know C#) so I have decided
I'm trying to learn how to validate a form and I have this problem:
I've recently installed Ruby on Rails 3.2 and have been trying to learn it.
I am still trying to learn Java and decided to take it 1 step
Please take it easy on me. I'm a newbie and is trying to learn

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.