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
答案 0 :(得分:0)
我认为问题可能与上一行有关,请尝试更改为:
Dim img As Byte() = dr("img")
并查看是否收到同样的错误。