注册 登录
编程论坛 VB.NET论坛

vb.net二进制流转换成图片

zhoushichuan 发布于 2011-09-17 00:15, 1219 次点击
如何从sql2000数据库中读取出二进制流,并将二进制流转换成图片显示在网页上?

1 回复
#2
jianjunfeng2012-03-30 16:29
回复 楼主 zhoushichuan
    Public Sub 查找4(ByVal 字符 As String, ByVal Pi As PictureBox, ByVal FR As PictureBox, ByVal str As String)
        Dim sql As String = "select PIC from prdt where PRD_NO = '" & 字符 & "'"
        Dim sqlConn As SqlClient.SqlConnection = New SqlClient.SqlConnection(str)
        sqlConn.Open()
        On Error Resume Next
        Dim sqlCmd As New SqlClient.SqlCommand(sql, sqlConn)
         = CommandType.Text
        Dim bt As Byte() = sqlCmd.ExecuteScalar()
        '  MsgBox(Fstr & sql)
        If Not bt Is Nothing Then
            If bt.Length > 0 Then
                Dim fs As New MemoryStream(bt, True)
                fs.Write(bt, 0, bt.Length)
                fs.Position = 0
                Pi.Image = Image.FromStream(fs)
            Else
                Pi.Image = FR.Image
            End If
        Else
            Pi.Image = FR.Image
        End If
        sqlConn.Close()
        sqlConn = Nothing
    End Sub
引用 Dim stry As String = .Item(0, .CurrentCell.RowIndex).Value.ToString.Trim
                查找4(stry, Me.PictureBox1, Me.PictureBox2, Ftps)

Ftps 为连接SQL服务器的语句
1