VB.Net Update Image In MySQL - Hallo sahabat Dev-Create, Pada Artikel yang anda baca kali ini dengan judul VB.Net Update Image In MySQL, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan
Artikel Browse Image Into PictureBox Using VB.NET,
Artikel mysql,
Artikel mysql database,
Artikel Retrieve Image From MySQL Database In VB.Net,
Artikel update,
Artikel vb.net,
Artikel VB.Net Update Image In MySQL, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.
Judul : VB.Net Update Image In MySQL
link : VB.Net Update Image In MySQL
Anda sekarang membaca artikel VB.Net Update Image In MySQL dengan alamat link https://dev-create.blogspot.com/2017/12/vbnet-update-image-in-mysql.html
Judul : VB.Net Update Image In MySQL
link : VB.Net Update Image In MySQL
VB.Net Update Image In MySQL
How To Edit An Image In MySQL Database Using VbNet
In This VB.Net Tutorial We Will See How To Browse Picture On Button Click And Display The Selected Picture Into A PictureBox And Insert The Image From PictureBox Into MySQL DataBase Table Using MySqlCommand With Parameters In Visual Basic.Net Programming Language And Visual Studio Editor.
Project Source Code:
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class Update_MySQL_Image
Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=s_t_d")
' display image from mysql into picturebox
Private Sub ButtonShow_Click(sender As Object, e As EventArgs) Handles ButtonShow.Click
Dim command As New MySqlCommand("SELECT `id`, `name`, `dscp`, `pic` FROM `mypics` WHERE `id` = @ID", connection)
command.Parameters.Add("@ID", MySqlDbType.UInt64).Value = TextBoxID.Text
Dim adapter As New MySqlDataAdapter(command)
Dim table As New DataTable()
Try
adapter.Fill(table)
Dim imgByte() As Byte
If table.Rows.Count = 1 Then
TextBoxName.Text = table(0)(1)
TextBoxDesc.Text = table(0)(2)
imgByte = table(0)(3)
Dim ms As New MemoryStream(imgByte)
PictureBox1.Image = Image.FromStream(ms)
Else
MessageBox.Show("No Data Found")
TextBoxName.Text = ""
TextBoxDesc.Text = ""
PictureBox1.Image = Nothing
End If
Catch ex As Exception
MessageBox.Show("ERROR")
TextBoxName.Text = ""
TextBoxDesc.Text = ""
PictureBox1.Image = Nothing
End Try
End Sub
' button browse image and display it into picturebox
Private Sub ButtonSelect_Img_Click(sender As Object, e As EventArgs) Handles ButtonSelect_Img.Click
Dim opf As New OpenFileDialog
opf.Filter = "Choose Image(*.JPG;*.PNG;*.GIF)|*.jpg;*.png;*.gif"
If opf.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(opf.FileName)
End If
End Sub
' button edit image and other data
Private Sub ButtonEDIT_Click(sender As Object, e As EventArgs) Handles ButtonEDIT.Click
Dim update_command As New MySqlCommand("UPDATE `mypics` SET `name`=@nm,`dscp`=@dc,`pic`=@img WHERE `id` = @ID", connection)
Dim ms As New MemoryStream
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
update_command.Parameters.Add("@nm", MySqlDbType.VarChar).Value = TextBoxName.Text
update_command.Parameters.Add("@dc", MySqlDbType.VarChar).Value = TextBoxDesc.Text
update_command.Parameters.Add("@ID", MySqlDbType.Int64).Value = TextBoxID.Text
update_command.Parameters.Add("@img", MySqlDbType.Blob).Value = ms.ToArray()
connection.Open()
If update_command.ExecuteNonQuery() = 1 Then
MessageBox.Show("UPDATED")
Else
MessageBox.Show("NOT UPDATED")
End If
connection.Close()
End Sub
End Class
///////////////OUTPUT:
Demikianlah Artikel VB.Net Update Image In MySQL
Sekianlah artikel VB.Net Update Image In MySQL kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel VB.Net Update Image In MySQL dengan alamat link https://dev-create.blogspot.com/2017/12/vbnet-update-image-in-mysql.html