我在VARBINARY
列的SQL Server中有一些数据,我只想知道如何在VB.NET中将它显示到PictureBox
。怎么做?
二进制数据类似于:
0x1F8B0800000000000400EDBD07601C499625262F6DCA7B7F4AF54AD7E.....(and a great many more bytes to come)......
答案 0 :(得分:0)
Private Sub sample()
Dim command, commandReader As New NpgsqlCommand
command.Connection = GetConnection()
command.CommandText = "select imgField from imgtable"
Dim productImageByte As Byte() = TryCast(command.ExecuteScalar, Byte())
If productImageByte IsNot Nothing Then
Using productImageStream As Stream = New System.IO.MemoryStream(productImageByte)
PPicBoxPhoto.Image = Image.FromStream(productImageStream)
End Using
End If
End Sub
postgresql
数据库和我提交的图像 bytea