gpt4 book ai didi

mysql - 当我单击 vb.net 中的数据网格时,如何从 mysql 检索 blob 到图片框

转载 作者:行者123 更新时间:2023-11-29 11:29:00 31 4
gpt4 key购买 nike

我正在vb.net中制作一个配置文件数据库程序,每个配置文件都有一个图片。它的数据类型是一个blob,我如何从mysql将其检索到图片框?

最佳答案

这是一个可以帮助您的简单代码片段:

cmd = New SqlCommand("select photo from Information where name='" & _
DataGridView1.CurrentRow.Cells(0).Value() & "'", con)
Dim imageData As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
If Not imageData Is Nothing Then
Using ms As New MemoryStream(imageData, 0, imageData.Length)
ms.Write(imageData, 0, imageData.Length)
PictureBox1.BackgroundImage = Image.FromStream(ms, True)
End Using
End If

关于mysql - 当我单击 vb.net 中的数据网格时,如何从 mysql 检索 blob 到图片框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37737463/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com