Partial Public Class KxEventDocument1 Inherits System.Web.UI.Page Private sqlcon As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("Provider=SQLOLEDB;Data Source=SGEN-SQL02;Initial Catalog=KX_Live;Integrated Security=True;").ConnectionString) Private sqlcmd As New SqlClient.SqlCommand() Private da As New SqlClient.SqlDataAdapter() Private dt As New DataTable() Private qstr As String Private b As Byte() Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Page.IsPostBack Then qstr = Request.QueryString("ID") 'Read PDF file from DATABASE table pdf field Dim sqlcmd As New SqlClient.SqlCommand("SELECT DataFile FROM CompanyActionAttachments WHERE (AttachmentID ='" + qstr + "')", sqlcon) 'use condition to retrieve particulatr PDF sqlcon.Open() da = New SqlClient.SqlDataAdapter(sqlcmd) da.Fill(dt) If dt.Rows.Count > 0 Then b = DirectCast(dt.Rows(0)(0), Byte()) 'Collect Bytes from database and write in Webpage Response.ContentType = "application/pdf" Response.BinaryWrite(b) End If End If End Sub End Class