Click to accumulate [C #] --- C # to upload word and save the path to the database, and save the file to the server. And read the server's word by name

Source: Internet
Author: User

Effect:

1.

.

.

Database:

Ideas:

Upload: first obtain the word physical address, then judge based on the file type, save it to the corresponding folder, and then insert the path to the database.

Read: First, find the file path in the database based on the input file name, and then read the file according to the path.

Code:

Note: You need to import the COM Library: Microsoft word 11.0 Object Library.

                                Page_Load(             SQLString = ConfigurationManager.ConnectionStrings[           UploadButton_Click(                                 (SqlConnection sqlcon =                        FullName = FileUpload1.PostedFile.FileName;                     FileInfo fi =                       name = fi.Name;                      type = fi.Extension;                      (type ==  || type ==                            SavePath = Server.MapPath();                         .FileUpload1.PostedFile.SaveAs(SavePath +  + name);                          sql =  + name +  + type +  + name +                          SqlCommand cmd =                            .label1.Text =                          .tb1.Text =                                                .label1.Text =                                 lbtn_Click(                                 (SqlConnection sqlcon =                        sql =  + tb1.Text.ToString() +                      SqlCommand cmd =                       cmd.CommandText =                     SqlDataReader sdr =                      ImagePath =                                                ImagePath = sdr[                                            oMissing =                       oWord =                      oWord.Visible =                       fileName =                     oDoc = oWord.Documents.Open(                      oMissing,  oMissing,  oMissing,  oMissing,                       oMissing,  oMissing,  oMissing,  oMissing,                       oMissing,  oMissing,  oMissing,  oMissing,                                                                                                                                                                                                                                                                                                                                                                                           }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.