本文介绍了如何保存和回收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

推荐答案


这篇关于如何保存和回收PictureBox图像到Sql Server数据库Varbinary(Max)列VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 09:31