我有一段代码,可以将Picturebox中的图像(在VB6中)保存到数据类型为Image的SQL数据库中,以下是输出结果:
Column Name = Picture
我的问题是如何将这里的图片
与我的SQL数据库进行比较? 我的目标是检查image3
中的图像是否存在于我的数据库中。
这是我的代码,但它没有起作用。
Dim arrImageByte() As Byte
Dim strPhotoPath As String
strPhotoPath = Image3.Picture & ".jpg"
Set rs = New ADODB.Recordset
Open strPhotoPath For Binary As #1
ReDim arrImageByte(FileLen(strPhotoPath))
fNum = FreeFile()
Open strPhotoPath For Binary As #fNum
Get #fNum, , arrImageByte
Close fNum
Text1.Text = FreeFile
rs.Open "select * from tbl_image with (nolock) where CONVERT(varbinary,[picture]) = '" & Text1.Text & "'", sql, 1, 1, 1
If rs.RecordCount = 0 Then
MsgBox "Image exist"
Else
MsgBox "Image does not exist."
End If
我认为最好的方法是将image3
转换成二进制(Picture Column
),然后执行选择命令。
请帮帮我,谢谢。
非常感谢!