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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:44:18+00:00 2026-06-12T15:44:18+00:00

the code below is my example of code how to connect and add by

  • 0

the code below is my example of code how to connect and add by textbox what i want now is how to add with dropdownlist… code sample how to add by dropdownlist someone please???

public partial class SQL_Test : System.Web.UI.Page
    {
        SqlConnection myConnection;
        DataSet dataSet;
        string sql;
        SqlDataAdapter dataAdapter;
        protected void Page_Load(object sender, EventArgs e)
        {
            myConnection = new SqlConnection("trusted_connection=yes;" + "database=DataBaseConnection;" + "connection timeout=30;");
            dataSet = new DataSet();
            sql = "SELECT Firstname,Surname FROM BasicInfo";
            dataAdapter = new SqlDataAdapter(sql, myConnection);
            //fill dataset
            dataAdapter.Fill(dataSet, "datafill");

            //bind database to gridviwe
            GridView1.DataSource = dataSet;
            GridView1.DataBind();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            myConnection.Open();
            SqlCommand AddCommand = new SqlCommand("INSERT INTO BasicInfo (Firstname,Surname) values(@a,@b)", myConnection);

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

                //Execute Query
                AddCommand.ExecuteNonQuery();

                //emptied textbox's
                TextBox1.Text = "";
                TextBox1.Text = "";

                //Redirect
                Response.Redirect("SQL-Test.aspx");
            }

            //close connection
            myConnection.Close();
        }
  • 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-12T15:44:20+00:00Added an answer on June 12, 2026 at 3:44 pm

    To get the selected value from a dropdown you can access the Text property.

    AddCommand.Parameters.AddWithValue("@a", TextBox1.Text);
    AddCommand.Parameters.AddWithValue("@d", DropDownList1.Text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The example code below works as as a server process. But when I add
UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
Given the example source code below, is it possible for someone to see the
I have a basic PHP question, take the code below for example, let's say
For this code example below, usually I would use [self fall]; instead of the
I know how to do this... I'll give example code below. But I can't
For example, I have the java code below: URL u = new URL(http://google.com); URLConnection
The example below shows the code I am using to test whether a user
For the example below: if a == 100: # Five lines of code elif
In the example below, if client code using GetPeople wanted to print the name

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.