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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:47:08+00:00 2026-06-18T17:47:08+00:00

I am developing a web application and need to use ALTER Table in it.

  • 0

I am developing a web application and need to use ALTER Table in it.
Here is my code:

ALTER TABLE [tablename] ADD [column-name] [Type] DEFAULT [default-value] NULL/NOT NULL 

Now i want to change [column-name] dynamically by a text box. How can i do that?
In addition i used @name in AddWithValue, but it doesn’t work!
Can any body help me?
Thanks

here is my whole code:

SqlConnection sqlconn4 = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConn"].ConnectionString);
                   SqlCommand sqlcomm4 = new SqlCommand("ALTER TABLE aspnet_Membership ADD @column int DEFAULT 0 NOT NULL", sqlconn4);

                    sqlcomm4.Parameters.AddWithValue("@column", TextBox1.Text);
                    sqlconn4.Open();
                    sqlcomm4.ExecuteNonQuery();
                    sqlconn4.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-18T17:47:09+00:00Added an answer on June 18, 2026 at 5:47 pm

    with sp_rename procedure you can change column name.

    sp_RENAME 'Table_First.Name', 'NameChange' , 'COLUMN'
    

    http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/

    public void AddNewColumn(string tableName, string columName, string dataType)
        {
            string commandText = String.Format("ALTER TABLE {0} ADD {1} {2} ", tableName,columName,dataType);
    
            using (var sqlConnection = new SqlConnection("===="))
            {
                var cmd = sqlConnection.CreateCommand();
                cmd.CommandText = commandText;
    
                sqlConnection.Open();
                cmd.ExecuteNonQuery();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application. For some reasons, I need to use external
I am developing an asp.net web application. I need to use java script to
I'm developing a web application and need to page ordered results. I normaly use
I am developing a web application, I need to use keyboard to open/switch tabs
I am using IIS7 Express while developing my web application. I need to use
I am developing a web application in PHP, I need to transfer many objects
I'm developing a simple web application where in I need to display number a
I am developing a Java Web Application using JSF, Spring and Hibernate. I need
I'm developing web-application, in this I want to add all months values on the
I'm developing web application supported by Spring Integration. I'm using 1.0.4.RELEASE. I use CGLib

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.