ADO.NET - How To: Delete a Column
Here is an example of removing (dropping) an existing column from a table of a Microsoft SQL Server database:
1 min read22 words1 code sample
Introduction#
This example demonstrates the removal of an existing column from a Microsoft SQL Server table:
C#
private void btnDatabase_Click(object sender, EventArgs e)
{
using (SqlConnection connection =
new SqlConnection("Data Source=(local);" +
"Database='Exercise1';" +
"Integrated Security=yes;"))
{
SqlCommand command =
new SqlCommand("ALTER TABLE Customers " +
"DROP Column DateIssued;",
connection);
connection.Open();
command.ExecuteNonQuery();
MessageBox.Show(
"The column named \"DateIssued\" has been deleted.");
}
}Home Copyright © 2011 C# Key

