Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hello
i want to insert and retrive documents like .doc/.txt file how can insert into database & how to retrive in web application .guide me or send snippets
Posted

Hi Sir,
You can visit this link
http://aspsnippets.com/Blue/Articles/Save-and-Retrieve-Files-from-SQL-Server-Database-using-ASP.Net.aspx
I hope this one can help you.

Thank You.
 
Share this answer
 
v2
Hi,


you can convert your file into byte array and you can store it into database.

you also need to enable fileStream in SQL Server 2008 R2. (don't have much idea about other database version)

Please go through this link.


this may help you,

thanks
-Amit
 
Share this answer
 
Hi,
You can use file upload control for inserting file into Database.In file upload control button click you can write this
C#
protected void UploadFile_Click(object sender, EventArgs e)
        {
            if (Fileupload.HasFile)
            {
                string inputfileName = Fileupload.FileName;
                               Fileupload.SaveAs(Server.MapPath("~/Attachments/")+ inputfileName);
                ViewState["FileUploadControl"] = inputfileName;
            }

        }

Here attachments is the fiel storage location folder name and this viewstate value can be assigned to database url field and that can be retrievedby using any lable or textbox like this
C#
qs.Attachment_URL = ViewState["FileUploadControl"].ToString();
                string Url = ConfigurationManager.AppSettings["InputPath"] + qs.Attachment_URL;
                hyplUrl.NavigateUrl = Url;
                hyplUrl.Text = qs.Attachment_URL;
                hyplUrl.Visible = true;

Here am using hyperlink for opening the url in another page.Input path means file storate location path taken as config file.

And qs is my class file object name.In class file am creating url variable and write connection string and added to database.
 
Share this answer
 
v2

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