Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

ExecuteNonQuery

Aleksey Nemiro edited this page Apr 5, 2014 · 1 revision

The ExecuteNonQuery method of the SqlClient class is used to perform queries that return no results.

For example, to update or delete data.

C#

using (SqlClient client = new SqlClient())
{
  client.CommandText = "DELETE FROM table WHERE id = @id"; 
  client.Parameters.Add("@id", SqlDbType.Int).Value = 5;
  client.ExecuteNonQuery();
}

Visual Basic .NET

Using client As New SqlClient()
  client.CommandText = "DELETE FROM table WHERE id = @id"
  client.Parameters.Add("@id", SqlDbType.Int).Value = 5
  client.ExecuteNonQuery()
End Using