VB.Net Insert Image Into MySQL - Hallo sahabat Dev-Create, Pada Artikel yang anda baca kali ini dengan judul VB.Net Insert Image Into 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 How To Insert Image In MySQL Database In VB.Net, Artikel image, Artikel insert, Artikel Insert Image To MySQL Database Using VB.Net, Artikel mysql, Artikel mysql database, Artikel vb.net, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : VB.Net Insert Image Into MySQL
link : VB.Net Insert Image Into MySQL

Baca juga


VB.Net Insert Image Into MySQL

How To Insert Image Into MySQL Database Using VbNet

insert picture in mysql in 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.



▶ Download All VB.NET Projects Source Code


Project Source Code:

Imports MySql.Data.MySqlClient
Imports System.IO

Public Class Insert_Image_Into_MySQL

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

    ' browse and display image button 
    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

    ' insert image button 
    Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Handles ButtonInsert.Click

        Dim ms As New MemoryStream
        PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)

        Dim command As New MySqlCommand("INSERT INTO `mypics`(`name`, `dscp`, `pic`) VALUES (@nm,@ds,@img)", connection)

        command.Parameters.Add("@nm", MySqlDbType.VarChar).Value = TextBoxName.Text
        command.Parameters.Add("@ds", MySqlDbType.VarChar).Value = TextBoxDesc.Text
        command.Parameters.Add("@img", MySqlDbType.Blob).Value = ms.ToArray()

        connection.Open()

        If command.ExecuteNonQuery() = 1 Then
            MessageBox.Show("Image Inserted")

        Else
            MessageBox.Show("Image Not Inserted")
        End If

        connection.Close()

    End Sub

    Private Sub Insert_Image_Into_MySQL_Load(sender As Object, e As EventArgs) Handles MyBase.Load

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

mysql insert picture to database table using visual basic.net






Demikianlah Artikel VB.Net Insert Image Into MySQL

Sekianlah artikel VB.Net Insert Image Into MySQL kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel VB.Net Insert Image Into MySQL dengan alamat link https://dev-create.blogspot.com/2017/12/vbnet-insert-image-into-mysql.html