Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Friends,

In my windows application I have to display image in Windows Form PictureBox which will be browsed by OpenFile Dialog, and then save PictureBox image to Sql Server 2008 R2 Varbinary(Max) Column and Show Picture saved in Sql Server 2008 R2 Varbinary(Max) column to PictureBox Using VB.NET 2010.


I have used the following code to load Picture from physical drive to PictureBox

VB
Private Sub btnPicBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPicBrowse.Click
        With Me.OpenFileDialog1
            .FileName = ""
            .Filter = "Image Files(*.BMP;*.JPG;*.JEPG;*.GIF)|*.BMP;*.JPG;*.JEPG;*.GIF|All files (*.*)|*.*"
            .RestoreDirectory = True
            .ValidateNames = True
            .CheckFileExists = True
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.PictureBox1.Image.Dispose()
                Me.PictureBox1.Image = System.Drawing.Image.FromFile(.FileName)
                Me.lblPicPath.Text = .FileName
            End If
        End With
    End Sub


Now I have to save this Image to SQL SERVER 2008 Database VarBinary (MAX) Column and Then Show Picture saved in Sql Server 2008 R2 Varbinary(Max) column to PictureBox Using VB.NET 2010.

Thanks & Regards

JYOTIRMOY
Posted
Comments
Sergey Alexandrovich Kryukov 30-May-13 13:39pm    
Why PictireBox? PictureBox is just a control you don't store (and it's is heavily abused; in very many cases, it is not needed). Just image, or bitmap.
—SA
Member 11520595 17-Mar-15 16:54pm    
$quot; Is giving error in vb.net 2008 why ?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900