Figure 723B Vbnet vbCDal Addressvb

Public Sub Delete(ByVal AdrsID As String) Dim oCmd As SqlCommand Dim strSQL As String strSQL = "EXEC usp_tblAddress_del " & AdrsID oCmd = New SqlCommand(strSQL, oConn) oCmd.CommandType = CommandType.Text Try

If oConn.State = ConnectionState.Closed Then oConn.Open() End If oCmd.ExecuteNonQuery() Catch oErr As Exception

Throw New Exception(oErr.ToString) End Try End Sub

The code to call the Delete Stored procedure is similar to the first method you used to select the records by their ID. Again, the ExecuteNonQuery tells ADO.NET that you are not interested in returning any rows and to close the connection when you are done.This requires less overhead for the data provider.

0 0

Post a comment