VB.Net Get Database Images Into DataGridView

VB.NET - How To Display Images From SQL Server To Datagridview Using Visual Basic.Net

                                                                                                                         

In This VB.NET Tutorial We Will See How To Retrieve And Show Image From Microsoft SQL DataBase Into Datagridview Using Visual Basic .NET Programming Language.


Project Source Code:

Imports System.Data.SqlClient

Public Class VBNET_Get_Images_From_SQL_To_DataGridView

    Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB; Integrated Security = true")

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

        Dim command As New SqlCommand("select * from Table_Images")
        command.Connection = connection

        Dim adapter As New SqlDataAdapter(command)

        Dim table As New DataTable()



        adapter.Fill(table)

        DataGridView1.AllowUserToAddRows = False

        DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        DataGridView1.RowTemplate.Height = 100

        Dim imgc As New DataGridViewImageColumn()

        DataGridView1.DataSource = table

        imgc = DataGridView1.Columns(3)

        imgc.ImageLayout = DataGridViewImageCellLayout.Stretch


    End Sub
End Class

///////////////OUTPUT:

Get Database Images Into DataGridView








Share this

Related Posts

Previous
Next Post »