-1
在表中image
列存儲爲0xFF ...如何在vb.net winforms圖像框中顯示此格式文件?我想下面的代碼,但沒有工作,顯示readtimeout/writetimeout錯誤..help me..advanced感謝..從vb.net中的SQL Server顯示圖像框中的圖像winforms
Private Sub DisplayNameAttribute_UserImage()
Try
strimage = "SELECT userimage from MKBLOGIN where empcode='" & str_empcode & "'"
imagedatabytes = objcommonvalidation.func_loadUserImage(strimage)
mem = New MemoryStream(imagedatabytes)
PictureBox1.Image = ToImage(imagedatabytes)
Catch ex As Exception
End Try
End Sub
Public Function func_loadEmpImage(ByVal str_query As String) As Byte()
Try
Dim ds As New DataSet
da = New SqlDataAdapter(str_query, con)
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
data = New Byte(0) {}
data = ds.Tables(0).Rows(0)("userimage")
End If
Return data.ToArray()
Catch ex As Exception
Return data.ToArray()
End Try
End Function
Public Shared Function ToImage(Data As Byte()) As Image
If Data Is Nothing Then
Return Nothing
End If
Dim img As Image
Using stream As New MemoryStream(Data)
Using temp As Image = Image.FromStream(stream)
img = New Bitmap(temp)
End Using
End Using
Return img
End Function
其不顯示 – Sreevardhan
請更多信息編輯。僅限代碼和「嘗試這個」的答案是不鼓勵的,因爲它們不包含可搜索的內容,也不解釋爲什麼有人應該「嘗試這個」。我們在這裏努力成爲知識的資源。 –