Accumulate [C #] --- C # to upload word files to the database as a stream and read the word files in the database.

Source: Internet
Author: User

Source: http://www.cnblogs.com/zmgdpg/archive/2005/03/31/129758.html

Effect:

Database:

Ideas:

First, save the word to the database: Get the size of the byte of the uploaded file, then read the byte from the stream, and then save the obtained stream to the database.

Read Database: Find the stream data in the database by name, and then use the reader BinaryWriter to read the stream file and save it to the specified directory.

Code:

                               Page_Load(               btn_Click(                            name =                          Stream fileStream =                           length =             [] wordData =                            fileStream.Read(wordData,                           DateTime time =                          SqlConnection conn =              conn.ConnectionString = ConfigurationManager.ConnectionStrings[             SqlCommand cmd =              cmd.Connection =             cmd.CommandText =              SqlParameter nameParam =  SqlParameter(, System.Data.SqlDbType.VarChar,              nameParam.Value =              SqlParameter timeParam =  SqlParameter(, System.Data.SqlDbType.DateTime,              timeParam.Value =                           SqlParameter contentParam =  SqlParameter(             contentParam.Value =                i =              (i >                   Response.Write(                                Response.Write(               btn1_Click(                                        SqlConnection conn =              conn.ConnectionString = ConfigurationManager.ConnectionStrings[             SqlCommand cmd =              cmd.Connection =                          cmd.CommandText =  + tb1.Text.ToString() +                              buffersize =                           [] outbyte =                                                                                 filePath =  + tb1.Text +                reader =                               fs =                  bw =                  startIndex =                                   reval = reader.GetBytes(, startIndex, outbyte,                                    (reval ==                                             startIndex +=                     reval = reader.GetBytes(, startIndex, outbyte,                                    bw.Write(outbyte, , ()reval -                   (reader.Read().ToString() !=                   Response.Write( + tb1.Text +                                 Response.Write(       }

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.