title: C# Alter Table and Add a column programmatically ASP.Net & SQL Server
body: <p>I have been trying to add a column programmatically in ASP.NET to modify the tables in SQL Server.</p>
  
  <p>Please see the following code:</p>
  
  <pre><code> string suppliernotxt = supplieridlist[1].ToString();
   //SqlCommand cmd2 = new SqlCommand("ALTER TABLE [ProductNormalDB] ADD suppliernotxt nvarchar(20) NULL", con);
   SqlCommand cmd2 = new SqlCommand("ALTER TABLE ProductNormalDB ADD @supplierlist nvarchar(20) NULL", con);
   cmd2.Parameters.AddWithValue("@supplierlist", suppliernotxt);
   //cmd2.Parameters.AddWithValue("@supplierlist", suppliernotxt.ToString());
   //cmd2.Parameters["@supplierlist"].Value = supplieridlist[x];
   cmd2.ExecuteNonQuery();
  </code></pre>
  
  <p><code>supplieridlist</code> is an array that acquires all the column names to add into the SQL Server database. For some reason the parametrized method is not working and shows the following error:</p>
  
  <blockquote>
    <p>Incorrect syntax near '@supplierlist'.</p>
  </blockquote>
  
  <p>The basic idea is to have a user select from a check box the name of the suppliers, based on the selected number of suppliers the array will create the supplier names for ex. if we selected 3 suppliers, the array will save <code>"Supplier1"</code>, <code>"Supplier2"</code>, <code>"Supplier3"</code> and then the <code>SqlCommand</code> is supposed to alter the table and add the new columns.</p>