2014-01-06 39 views

回答

0

試試這個

Dim path As String = (Microsoft.VisualBasic.Left(Application.StartupPath, Len(Application.StartupPath) - 9)) 
Dim con As New SqlConnection("Data Source=[Server Name];AttachDbFilename=" & _ 
     path & "Database1.mdf;Integrated Security=True;User Instance=True") 
Dim cmd As SqlCommand 

cmd = New SqlCommand("select photo from Information where name='image1'", 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 
相關問題