VB.NET Delete Data From SQL Server Database

VB.NET - How To Delete Record From SqlServer DataBase Using Visual Basic .Net

                                                                                                                         

In This VB.NET Tutorial We Will See How To Remove Records From Microsoft SQL DataBase In Visual Basic .NET Programming Language.


Project Source Code:


Imports System.Data.SqlClient

Public Class VBNET_SQL_DELETE

    Private Sub BTN_DELETE_Click(sender As Object, e As EventArgs) Handles BTN_DELETE.Click

        Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB; Integrated Security = true")
        Dim command As New SqlCommand("DELETE FROM Users WHERE Id = @id", connection)

        command.Parameters.Add("@id", SqlDbType.Int).Value = TextBoxID.Text

        connection.Open()

        If command.ExecuteNonQuery() = 1 Then

            MessageBox.Show("User Deleted")

        Else

            MessageBox.Show("User Not Deleted")

        End If

        connection.Close()

    End Sub
End Class


///////////////OUTPUT:

vb.net sqlserver delete record







Share this

Related Posts

Previous
Next Post »

1 comments:

comments