老师,这段代码是大红袍老师给的,我怎么测试都实现不了在表中直接插入图片,好着急啊。帮忙改动一下Dim c As new camera
Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1")
Dim dr As DataRow = Tables("T_信息表").Current.DataRow
c.Capture() '开始照相
If c.image IsNot Nothing Then '照相成功
pic.Image = c.Image
Dim imgStream As New IO.MemoryStream
Dim b As New Bitmap(pic.Image)
b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim imageByte As Byte() = imgStream.GetBuffer
imgStream.Dispose()
Dim ImageString As String = BitConverter.ToString(imageByte).Replace("-", "") ' SQLCommand 不能直接Insert 二进制,只能拼接SQL语句,所以这里把二进制变成字符
Dim cmd As SQLCommand = new SQLCommand()
cmd.C
cmd.CommandText = "Insert Into T_信息表 (ICON) values (0x" + ImageString + ")" '这里的ImageString 就是前4条几句根据图片转换来的字符串
cmd.ExecuteNonQuery()
End If