If you have code on your ASP.NET pages that allows visitors to enter a record, or where you add records through code without their input, you will likely need to delete records from your pages. This technique shows you how to use a SQL Delete query to delete records from an SQL Server table.
When the page first loads, the following code will populate the DropDownList control:
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)If Not IsPostBack ThenDim DBConn as SQLConnectionDim DBCommand As SQLDataAdapter Dim DSPageData as New DataSet
DBConn = New SQLConnection("server=localhost;" _& "Initial Catalog=TT;" _& "User Id=sa;" _"Password=yourpassword;") DBCommand = New SQLDataAdapter _ ("Select LastName + ‘ + FirstName "
& "as EmpName, EmpID " _& "From Employees " _& "Order By LastName, FirstName", DBConn)
DBCommand.Fill(DSPageData, _ "Employees")ddlEmps.DataSource = _DSPageData.Tables("Employees").DefaultViewddlEmps.DataBind()End IfEnd Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)