Asp.Net Programming Asp.Net > Code Snippets Code Examples Executing Transact-SQL DELETE statement using SQLCommand Executing Transact-SQL DELETE statement using SQLCommand <%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQLClient" %> <script language="VB" runat="server"> Sub Page_Load(Source as Object, E as EventArgs) Dim cnn As New SQLConnection("server=LOCALHOST;User id=SA;password=;database=Northwind") Dim UpdateCommand As SqlCommand = New SqlCommand() UpdateCommand.Connection = cnn Dim sql As String sql = "Delete from categories WHERE CategoryID = @CatID" UpdateCommand.CommandText = sql UpdateCommand.Parameters.Add("@CatID", SqlDbType.Int).Value = 14 Try cnn.Open() UpdateCommand.ExecuteNonQuery() Catch ex As Exception response.Write(ex.ToString()) Finally cnn.Close() End Try end sub