繁体   English   中英

当我单击vb.net中的datagrid时,如何从mysql到图片框检索blob

[英]How to retrieve a blob from mysql to picturebox when i click the datagrid in vb.net

我正在vb.net中创建一个配置文件数据库程序,每个配置文件都有一个picture.its数据类型是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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM