VB.Net Delete MySQL Data

How To Remove Data From MySQL Database Using VbNet

VB.Ne Andt MySQL Delete

In This VB.Net Tutorial  We Will See How To Delete The Selected Data From MySQL DataBase Table Using TextBox For The ID  To Just Remove The Data With This Specific ID Using MySqlCommand With Parameters In Visual Basic.Net  Programming Language And Visual Studio Editor.


Project Source Code:

Imports MySql.Data.MySqlClient

Public Class Delete_MySQL_Data

    Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=s_t_d")

    Private Sub ButtonDelete_Click(sender As Object, e As EventArgs) Handles ButtonDelete.Click

        Dim command As New MySqlCommand("DELETE FROM `student` WHERE `Id` = @id", connection)

        command.Parameters.Add("@id", MySqlDbType.Int64).Value = TextBox1.Text

        connection.Open()

        Try

            If command.ExecuteNonQuery() = 1 Then

                MessageBox.Show("Data Deleted")

            Else

                MessageBox.Show("Error")

            End If

        Catch ex As Exception

            MessageBox.Show("Something Wrong")

        End Try


        connection.Close()

    End Sub
End Class
      
///////////////OUTPUT:

delete data from mysql database using vb.net




Share this

Related Posts

Previous
Next Post »

1 comments:

comments
Anonyme
10 mai 2018 à 19:59 delete

MORE CODE :)

Reply
avatar