How To Add A New Item To MenuStrip From MySQL Database In VbNet
In This VB.Net Tutorial We Will See How To Create A New ToolStripMenuItem With Image And Text From MySQL Database Table And Add This ToolStripMenuItem To A MenuStrip Element Using MySqlDataAdapter + DataTable + MemoryStream In Visual Basic.Net Programming Language And Visual Studio Editor.
Project Source Code:
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class Add_Item_To_MenuStrip_From_MySQL
Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=s_t_d")
Private Sub Add_Item_To_MenuStrip_From_MySQL_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim adapter As New MySqlDataAdapter("SELECT * FROM `mypics`", connection)
Dim table As New DataTable()
adapter.Fill(table)
For i As Integer = 0 To table.Rows.Count - 1 Step +1
Dim img() As Byte
img = table(i)(3)
Dim ms As New MemoryStream(img)
Dim pic As Image = Image.FromStream(ms)
MenuStrip1.Items.Add(table(i)(1), pic)
Next
End Sub
End Class
///////////////OUTPUT:
Post A Comment:
0 comments: