VB.NET - How To Retrieve Image From SQL Server DataBase Using Visual Basic.Net
In This VB.NET Tutorial We Will See How To Get And Display Image From Microsoft SQL Server DataBase Using Visual Basic .NET Programming Language.
Project Source Code:
Imports System.Data.SqlClient
Imports System.IO
Public Class VBNET_Get_Image_From_SQL
Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB; Integrated Security = true")
Private Sub BTN_SHOW_Click(sender As Object, e As EventArgs) Handles BTN_SHOW.Click
Dim command As New SqlCommand("select * from Table_Images where id = @id", connection)
command.Parameters.Add("@id", SqlDbType.VarChar).Value = TextBoxID.Text
Dim table As New DataTable()
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(table)
If table.Rows.Count() <= 0 Then
MessageBox.Show("No Image For This Id")
Else
TextBoxID.Text = table.Rows(0)(0).ToString()
TextBoxName.Text = table.Rows(0)(1).ToString()
TextBoxDesc.Text = table.Rows(0)(2).ToString()
Dim img() As Byte
img = table.Rows(0)(3)
Dim ms As New MemoryStream(img)
PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
End Class
///////////////OUTPUT:
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :