这是我保存和检索的代码,检索无效。
Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
Dim str As New MemoryStream
Pic.Image.Save(str, Imaging.ImageFormat.Jpeg)
Dim buffer(CInt(str.Length - 1)) As Byte
str.Position = 0
str.Read(buffer, 0, CInt(str.Length))
Try
Dim d As New DAL
If printchck.Checked = True Then
d.Dataedit(String.Format("insert into labdetails ( labnme,labspecial,labadress,labphone,labtime,lablogo,labprint)values('{0}','{1}','{2}','{3}','{4}','{5}',{6})", txtlabname.Text, txtspeciality.Text, txtadress.Text, txtphone.Text, txttime.Text, buffer, "Yes"))
Else
d.Dataedit(String.Format("insert into labdetails ( labnme,labspecial,labadress,labphone,labtime,lablogo,labprint)values('{0}','{1}','{2}','{3}','{4}','{5}',{6})", txtlabname.Text, txtspeciality.Text, txtadress.Text, txtphone.Text, txttime.Text, buffer, "No"))
End If
MessageBox.Show("تم الحفظ") ' saved
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub retriveimage()
Dim dt As DataTable = New DAL().selectdatatable("select lablogo from labdetails")
Dim img_buffer() As Byte = dt.Rows(0).Item("lablogo")
Dim img_stream As New MemoryStream(img_buffer)
img_stream.Write(img_buffer, 0, img_buffer.Length)
' Pic.Image = Image.FromStream(img_stream)
Pic.Image = Image.FromStream(img_stream) ' error here, Parameter is not valid
Pic.SizeMode = PictureBoxSizeMode.StretchImage
img_stream.Close()
End Sub