How To Edit Data In MySQL Database Using VbNet
In This VB.Net Tutorial We Will See How To Get Data From TextBoxes And DateTimePicker And Update The Selected Data From MySQL DataBase Table Using ID To Just Edit 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 Update_MySQL_Data
Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=s_t_d")
Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Handles ButtonInsert.Click
Dim command As New MySqlCommand("UPDATE `student` SET `FullName`=@fn,`Address`=@adds,`BirthDate`=@brd WHERE `Id` =@id", connection)
command.Parameters.Add("@id", MySqlDbType.Int64).Value = TextBox1.Text
command.Parameters.Add("@fn", MySqlDbType.VarChar).Value = TextBox2.Text
command.Parameters.Add("@adds", MySqlDbType.VarChar).Value = TextBox3.Text
command.Parameters.Add("@brd", MySqlDbType.Date).Value = DateTimePicker1.Value
connection.Open()
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("Data Updated")
Else
MessageBox.Show("ERROR")
End If
connection.Close()
End Sub
End Class
///////////////OUTPUT:
Post A Comment:
0 comments: