In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "ASP.NET and SQL Server database picture storage how to achieve", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "ASP.NET and SQL Server database picture storage how to achieve" this article.
1 introduction
With the advent of the Internet era, a variety of Internet-based applications emerge in endlessly, most of which use picture data and need to display the pictures in the user interface. Here is an implementation method to store the picture in a folder. and then display as required. The specific implementation step is to store the additional information recorded such as the picture path in the database, while the real picture file is stored in a folder. This method is a good solution.
2 the processing method of the picture
There are two ways to deal with pictures: ① picture data is directly stored on the hard disk as a file, and additional information about the picture is saved in the database (path, file name, comments …) ② pictures are stored directly in the database. These two approaches have their own advantages and disadvantages. The picture file is stored in the database for easy management and maintenance, while the hard disk may cause data inconsistency because the picture file is accidentally deleted: but the picture is not easy to modify and edit in the database. At the same time, it will cause the Icano consumption when the database reads the data, but putting it on the hard disk will not cause this problem. Therefore, for small files, it is recommended to be easy to manage in the database, while for large files, they can not be placed in the database, otherwise the database table will produce a large number of fragments of data files.
3 Image storage method: ASP.NET and SQL Server database picture storage
The system uses ASP.NET and SQL Server database to store pictures. Store the picture in the directory specified by the hard disk, and store the relative storage path and other ancillary information of the picture in the database. The language used in the development platform is VB, and the database access technology is ADO.NET. According to the access mechanism, the OleDb mechanism in ADO.NET is adopted.
3.1 Establishment of database tables
For the picture storage in the whole picture management system, it is necessary to establish a picture content table (myimg), whose structure is shown in Table 1.
3.2 configuration of background database
The picture management system uses SQL Server 2000 database. The code is as follows:
3.3 add Picture Page
Go to the page to add pictures and store the image path to the database.
3.3.1 Page example
Add a picture page as shown in figure 1.
3.3.2 upload method of pictures
Click the "Browse" button shown in figure 1, and the "Select File" dialog box of the windows operating system will pop up. After selecting the appropriate picture, click "Open".
Then click the "upload File" button, and if the upload is successful, a prompt will be given, as well as the relative path of the picture.
Copy the relative path of the uploaded picture to the Picture path text box. and enter the picture title, picture description, select the column to which the picture belongs, and * click the submit button.
If the information is successfully written to the database, a message indicating the success of adding the picture will be given.
3.4 Database information used on the page
The add new picture page uses the myimg table in the database to write the legal information of the picture entered by the user to the table, including all the fields of the myimg table.
These are all the contents of the article "how to store pictures in ASP.NET and SQL Server databases". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.