0
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim str As String
Dim dr As SqlDataReader

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    str = "select * from llr where llrno='" & TextBox1.Text & "'"
    cmd = New SqlCommand(str, con)
    con.Open()
    dr = cmd.ExecuteReader()
    If dr.HasRows Then
        dr.Read()
        Dim img As Byte() = DirectCast(dr("img"), Byte())
        Dim ms As New MemoryStream(img)
        PictureBox1.Image = Image.FromStream(ms)
    End If
    dr.Close()
    cmd.Dispose()
    con.Close()
End Sub
4

1 回答 1

0

我认为问题可能与上一行有关,请尝试更改为:

Dim img As Byte() = dr("img") 

看看你是否得到同样的错误。

于 2013-09-12T14:28:03.887 回答