将存储在PictureBox中的图片保存到数据库

时间:2020-09-14 18:06:24

标签: vb.net ms-access

我想保存显示在MS Access中PictureBox中的图片,就我而言,我不想使用OpenFileDialog方法(它对我来说很好用)。我只是想将软件启动时PictureBox1中显示的默认图片存储到数据库中。问题是:它在数据库中存储了黑色图像,检索图像并将其显示在PictureBox中时可以看到它。

部分代码:

Private Sub saveimage()
    Try
        
            Dim ms As New System.IO.MemoryStream
            Dim bmpImage As New Bitmap(PictureBox1.Image)
            bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
            bytImage = ms.ToArray()
            ms.Close()
        
    Catch ex As Exception
    End Try
End Sub

0 个答案:

没有答案