楼主可以参照下边这个过程:将表中的图片字段生成文件,然后要将这个图片文件放入picturebox应该没问题吧....Sub ReadPic() Try Dim fs As IO.FileStream Dim bw As IO.BinaryWriter Dim conn As New SqlClient.SqlConnection("server=(local);database=tempdb;uid=sa;pwd=;") Dim logoCMD As New SqlClient.SqlCommand("select id,photo from testPhoto", conn) Dim bufferSize As Integer = 100 Dim outbyte(bufferSize - 1) As Byte Dim retval As Long Dim startIndex As Long = 0 Dim FN as String Dim pub_id As String = "" conn.Open() Dim myReader As SqlClient.SqlDataReader = logoCMD.ExecuteReader(CommandBehavior.SequentialAccess) Do While myReader.Read() pub_id = myReader("id") FN="image" & pub_id & ".bmp" fs = New IO.FileStream(FN, IO.FileMode.OpenOrCreate, IO.FileAccess.Write) bw = New IO.BinaryWriter(fs) startIndex = 0 retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize)
Do While retval = bufferSize bw.Write(outbyte) bw.Flush() startIndex += bufferSize retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize) Loop bw.Write(outbyte, 0, retval - 1) bw.Flush() bw.Close() fs.Close() Loop conn.Close() myReader.Close() Catch ex As Exception ........ End Try End Sub
冰戈--->使用asp.net将图片上传并存入SqlServer中,然后从SqlServer中读取并显示出来
Try
Dim fs As IO.FileStream
Dim bw As IO.BinaryWriter
Dim conn As New SqlClient.SqlConnection("server=(local);database=tempdb;uid=sa;pwd=;")
Dim logoCMD As New SqlClient.SqlCommand("select id,photo from testPhoto", conn)
Dim bufferSize As Integer = 100
Dim outbyte(bufferSize - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim FN as String Dim pub_id As String = "" conn.Open()
Dim myReader As SqlClient.SqlDataReader = logoCMD.ExecuteReader(CommandBehavior.SequentialAccess) Do While myReader.Read()
pub_id = myReader("id")
FN="image" & pub_id & ".bmp"
fs = New IO.FileStream(FN, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
bw = New IO.BinaryWriter(fs) startIndex = 0
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize)
Do While retval = bufferSize
bw.Write(outbyte)
bw.Flush()
startIndex += bufferSize
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize)
Loop bw.Write(outbyte, 0, retval - 1)
bw.Flush() bw.Close()
fs.Close()
Loop
conn.Close()
myReader.Close()
Catch ex As Exception
........
End Try End Sub
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6404
http://blog.csdn.net/adandelion/articles/465433.aspx