The ExecuteNonQuery() Method

The ExecuteNonQuery() method executes commands that don’t return a result set, such as INSERT,
DELETE, and UPDATE. The ExecuteNonQuery() method returns a single piece of information—the
number of affected records.
Here’s an example that uses a DELETE command by dynamically building a SQL string:
SqlConnection con = new SqlConnection(connectionString);
string sql = "DELETE FROM Employees WHERE EmployeeID = " + empID.ToString();
SqlCommand cmd = new SqlCommand(sql, con);
try
{
con.Open();
int numAff = cmd.ExecuteNonQuery();
HtmlContent.Text += string.Format("
Deleted {0} record(s)
",
numAff);
}
catch (SqlException exc)
{
HtmlContent.Text += string.Format("Error: {0}

", exc.Message);
}
finally
{
con.Close();
}

: