Click here to Skip to main content
15,895,813 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends
can u please give me solution for how we can retrieve pdf file from sql database.
currently i am working with .net framework 4.0 and sql 2008
Posted

protected void Page_Load(object sender, EventArgs e)
{
int imageid = Convert.ToInt32(Request.QueryString["ACTUAL_IMAGE_PDF"]);SqlDataReader imageContent = GetImage(imageid);
 
imageContent.Read();
Response.ContentType = imageContent["ImageType"].ToString();
 
Response.OutputStream.Write((byte[])imageContent["ImageFile"], 0, System.Convert.ToInt32(imageContent["ImageSize"]));
Response.End();
}
private SqlDataReader GetImage(int imageid)
{
 
SqlConnection myConnection = new SqlConnection("Data Source=*********");SqlCommand myCommand = new SqlCommand("Select * From DBO.RIMS_TEST_TABLE Where imageid=@ImagePDF_Name", myConnection);
 
SqlParameter imageIDParameter = new SqlParameter("@ImageId", SqlDbType.Int);
 
imageIDParameter.Value = imageid;
 
myCommand.Parameters.Add(imageIDParameter);
 
myConnection.Open();
 
 }
 
}
 
Share this answer
 
v2
Comments
[no name] 12-Jul-11 1:58am    
Edited for Code Block.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900