ASP.NET SQL Delete

'Declare and create an instance of the object(CON) from the SqlConnetion Class
Dim CON as New SqlConnection("server= webserve;database=student;uid=student;pwd=icc;")

'Declare variable(SQL) and assign its value
Dim SQL as String="Delete from Products where pid=" & ProdID.text

'Declare and create an instance of the object(CMD) from SqlCommand Class
Dim CMD as New SqlCommand (SQL,CON)

'Execute Insert
Con.open()
CMD.ExecuteNonQuery()
Con.close()

‘ Display a message to the user
msg.text="Record Deleted Successfully"

The Data Table: In-memory table used to store and manipulate data:

‘Declare a Datatable and Datarow object
Dim DT as DataTable
Dim DR as DataRow

‘Create an instance of datatable
DT = New DataTable("TableName")

‘Create the table columns
DT.Columns.Add("ID",GetType(Integer))
DT.Columns.Add("Name",GetType(String))
DT.Columns.Add("Price",GetType(Decimal))

‘Set the first table column as primary key
Dim PK(0) as DataColumn
PK(0) = DT.Columns(0)
DT.PrimaryKey = PK

‘Add row to datatable
DR = DT.NewRow
     DR("ID") = 1000
     DR("Name") = “Computer”
     DR("Price") = 400
DT.Rows.Add(DR)

‘Delete row from datatable
DR = DT.Rows.Find(1000)
If Not DR Is Nothing Then
          DR.Delete()
End If

‘Update a column value on datatable
DR = DT.Rows.Find(1000)
If Not DR Is Nothing Then
          DR("Price") = 500
End If