ASp.net

Sunday, January 31, 2016

how to create delete button in asp net




use Below code for delete data from Sql server in asp.net :


Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
Try Dim RowsAffected As Integer = 0 
con.Open() 
Dim cq As String = String.Format("delete from UnitType where UnitTypeID= {0}", TextBox1.Text) 
cmd = New SqlCommand(cq) With {.Connection = con} 
RowsAffected = cmd.ExecuteNonQuery() 
Label5.Text = "Successfully deleted" 
FillGrid() 
TextBox1.Text = "" 
TextBox2.Text = "" 
If con.State = ConnectionState.Open Then 
con.Close() 
End If 
Catch ex As Exception 
Response.Write(ex.Message) 
End Try 
End Sub

No comments:

Post a Comment

MM Online Express | Best product Review and Online Marketing site

MM Online Express | Best product Review and Online Marketing site