Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("FileID") IsNot Nothing Then
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("AUTO-INFOConnectionString1") _
.ConnectionString
Dim strQuery As String = "select File_P from Product where ID_P=@id"
Dim cmd As SqlCommand = New SqlCommand(strQuery)
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(Request.QueryString("ImageID"))
Dim con As New SqlConnection(strConnString)
Dim sda As New SqlDataAdapter
cmd.CommandType = CommandType.Text
cmd.Connection = con
Dim dt As New DataTable
Try
con.Open()
sda.SelectCommand = cmd
sda.Fill(dt)
Catch ex As Exception
dt = Nothing
Finally
con.Close()
sda.Dispose()
con.Dispose()
End Try
If dt IsNot Nothing Then
Dim bytes() As Byte = CType(dt.Rows(0)("File_P"), Byte())
Response.Buffer = True
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.BinaryWrite(bytes)
Response.Flush()
Response.End()
End If
End If
End Sub