Delete data using sql statements : SqlCommand Delete « ADO.Net « C# / CSharp Tutorial






using System;
using System.Data;
using System.Data.SqlClient;

class MainClass
{
  static void Main(string[] args)
  {
    SqlConnection MyConnection = new SqlConnection("server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;");

    MyConnection.Open();

    String MyString = "DELETE Employee";
    SqlCommand MyCmd = new SqlCommand(MyString, MyConnection);

    MyCmd.ExecuteScalar();
    MyConnection.Close();
  }
}








32.19.SqlCommand Delete
32.19.1.Delete data using sql statements
32.19.2.Execute nonquery to delete a record (row)
32.19.3.Deleting Data