我是编程新手,我曾尝试创建一个工资单,其中包含一张可以通过数据库检索的图片。
问题是每当我要保存一些new employee information时
不放置图片,它将重定向到此错误:
System.Windows.Forms.PictureBox.Image.get返回无。这是一张图片,我想不出如何解决它,因为在给定的示例中没有实例使用图片框
Imports System.IO
Public Class AddNewEmployee
Dim connection As New SqlConnection("Server = DESKTOP-BBDJH6Q; Database = EmmeSubic; Integrated Security = true")
Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim command As New SqlCommand("insert into UserDetails(Picture) values ( @Picture)", connection) 'i removed the other things included here to define my question clearly for the picture is my only concern
Dim pic As New MemoryStream
ImgBox.Image.Save(pic, ImgBox.Image.RawFormat)
command.Parameters.Add("@Picture", SqlDbType.Image).Value = pic.ToArray()
end sub