|
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: |
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.");
}
}
|
|