如何把写入image数据类型的doc、jpeg、text文件读出,并显示在网页上?
Try
Dim filename As String
Dim fileType As String
Dim fileSize As String
Dim fileDataCol As Int32 = 4
Dim execCommand As SqlCommand = New SqlCommand()
Dim fs As System.IO.FileStream
Dim file As System.IO.FileInfo
With execCommand
.CommandText = "PubS_GetAccessoriesByNoid"
.Connection = New SqlConnection(OA.Common.OAConfiguration.ConnectionString)
.CommandType = CommandType.StoredProcedure
.Parameters.Add(New SqlParameter("@noid", SqlDbType.Int)).Value = noid
.Connection.Open()
Dim dr As SqlDataReader = .ExecuteReader()
dr.Read()
Dim b(CType(dr.GetBytes(fileDataCol, 0, Nothing, 0, Int32.MaxValue), Int32)) As Byte
dr.GetBytes(fileDataCol, 0, b, 0, b.Length)
fileType = dr.GetString(2)
fileSize = b.Length.ToString
filename = dr.GetString(1)
dr.Close()
.Connection.Close()
HttpContext.Current.Response.Clear()
Response.ContentType = fileType
Response.Clear()
Response.AddHeader("Content-Length", fileSize)
Response.AddHeader("Content-Disposition", "inline;filename=" & filename)
Response.OutputStream.Write(b, 0, b.Length)
End With
Catch ex As SqlException
End Try
Me.Response.End()
Displaying Images that Reside in a Database
http://www.4guysfromrolla.com/webtech/060100-1.shtml