这边定义一个CMD就是插入数据库的
cmd.Parameters.Add("@图片", SqlDbType.Binary, Integer.MaxValue - 1)
If Not (PictureBox1.Image) Is Nothing Then
PictureBox1.Image.Dispose()
PictureBox1.Image = Nothing
Dim file As IO.FileStream
Dim abytes() As Byte
file = New IO.FileStream(filename, IO.FileMode.Open)
abytes = Array.CreateInstance(GetType(Byte), file.Length)
file.Read(abytes, 0, file.Length)
cmd.Parameters("@图片").Value = abytes
ElseIf PictureBox1.Image Is Nothing Then
Dim file As IO.FileStream
Dim abytes() As Byte = Array.CreateInstance(GetType(Byte), SqlDbType.Image)
cmd.Parameters("@图片").Value = abytes
End If
cmd.ExecuteNonQuery()
MsgBox("添加成功!!")