Delete Data From SQL (ASP.Net / VB.Net)


Imports System.Data
Imports System.Data.SqlClient
Public Class delete
    Inherits System.Web.UI.Page
    Dim cmd As SqlCommand
    Dim cn As New SqlConnection("Data Source=SARIB-ALI\SQLEXPRESS;Initial Catalog=infra;Integrated Security=True")

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        cn.Close()
        cn.Open()
        cmd = New SqlCommand("delete from table_1 where product = @p or price = @pr", cn)
        cmd.Parameters.AddWithValue("@p",TextBox1.Text)
        cmd.Parameters.AddWithValue("@pr", TextBox2.Text)
        cmd.ExecuteNonQuery()
        MsgBox("Record Deleted")
    End Sub
End Class

No comments:

Post a Comment