Click here to Skip to main content
16,016,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to upload and download a pdf file in sqlserver database in asp.net?
Thanks.
D.K.Dixit
Posted
Comments
Anuja Pawar Indore 11-Nov-11 1:45am    
What do you mean by "Regarding to ask a Question". Please make it meaningful and to the point so that you get proper help
KiranBabu M 11-Nov-11 2:26am    
"Regarding to ask a Question" will not sound a good subject.
Give specific subject to your question

 
Share this answer
 
Comments
Uday P.Singh 11-Nov-11 1:54am    
5ed :)
Mehdi Gholam 11-Nov-11 2:00am    
Thanks
to uplaod file on server
C#
protected void btnSub_Click(object sender, EventArgs e)
    {
        try
        {
            string filename = FileUpload1.FileName;
            string filename1 = FileUpload2.FileName;
            FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename.Trim()));
            FileUpload2.PostedFile.SaveAs(Server.MapPath("~\\Uploadform\\" + filename1.Trim()));
            string path = "~\\Uploadform\\" + filename.Trim();
            string path1 = "~\\Uploadform\\" + filename1.Trim();
            SqlConnection con = new SqlConnection(str);
            cmd = new SqlCommand("Insert into Circular(title,type,url1,url2) values('" + txttitle.Text + "','" + txttype.Text + "','" + path + "','" + path1 + "')", con);
            lblinfo.Text = " Uploaded Successfully ";
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }

your file can be simply download/open as
C#
Response.Redirect(pdfurlfetchfromdatabase);
 
Share this answer
 
Means you need to store a file in Database ? if i am roght then here read the following.

To store a file in database you need to convert it to ByteArray[]. You can use dataType as Image, Vatbinary.

To download file from database, you need to read ByteArray and write it on pdf file using
system.Io.WriteAllBytes()

here is link[^] for your help.
 
Share this answer
 

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