如何保存和回收PictureBox图像到Sql Server数据库Varbinary(Max)列VB.NET

如何保存和回收PictureBox图像到Sql Server数据库Varbinary(Max)列VB.NET

问题描述:

亲爱的朋友们,



在我的Windows应用程序中,我必须在Windows Form PictureBox中显示图像,该图像将由OpenFile Dialog浏览,然后将PictureBox图像保存到Sql使用VB.NET 2010将Server 2008 R2 Varbinary(Max)列和显示图片保存在Sql Server 2008 R2 Varbinary(Max)列到PictureBox中。





我使用以下代码将图片从物理驱动器加载到PictureBox



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

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





现在我必须将此图像保存到SQL SERVER 2008 Da tabase VarBinary(MAX)Column然后使用VB.NET 2010将保存在Sql Server 2008 R2 Varbinary(Max)列中的图片保存到PictureBox。



谢谢&问候



JYOTIRMOY



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

老实说,回答这么多次问题并不好然后再次。请看这里:

http://www.codeproject.com/search.aspx?doctypeid=5&q=database+%28image+OR+picture%29+%28store+OR+get+OR+检索%29 [ ^ ],



http://www.codeproject .com / search.aspx?doctypeid = 5& q =数据库+%28image + OR +图片%29 +%28store + OR +获取+ OR +检索%29 + PictureBox [ ^ ]。



-SA
Honestly, this is not good to answer the question asked so many times again and again. Just look here:
http://www.codeproject.com/search.aspx?doctypeid=5&q=database+%28image+OR+picture%29+%28store+OR+get+OR+retrieve%29[^],
or
http://www.codeproject.com/search.aspx?doctypeid=5&q=database+%28image+OR+picture%29+%28store+OR+get+OR+retrieve%29+PictureBox[^].

—SA