When saving large files to MSSQL in Asp.net, the following two key problems need to be solved:
- Files must be stored in MSSQL in multiple parts;
- When the file is large, it takes a long time to save the file to MSSQL. The ASP. NET page may encounter a timeout error and cause the operation to fail.
The following two articlesArticleThe above two problems are well solved:
- How to read and write a file to and from a blob column by using chunking In ADO. NET and Visual C #. net
- Executing long running operations-Part II
Article 1 solves the problem of time-out errors caused by processing tasks for a long time using multiple threads. This article provides a practical example based on the above two documents for your reference.
Routine download: http://files.cnblogs.com/bestcomy/FileToMSSQL.rar
Routine installation steps:
- Decompress filetomssql.rar and set the decompressed folder to a virtual directory;
- Make sure that you have a connectable MSSQL with the northwind database. In this example, the categories data table is used;
- Make sure that the connstr database connection string in the <etettings> Configuration section of Web. config In the example is correct, which corresponds to your own MSSQL environment.
- Unexpectedly, you can use this routine to access default. aspx under the filetomssql virtual directory through IE.