---- Active Server Pages (ASP) is the script compiling environment on the server. You can use it to create dynamic web pages or generate powerful web applications. Program ASP makes the work very simple. ASP pages are files that contain HTML tags, text, and script commands. You can call ActiveX components to execute tasks on ASP pages, such as connecting to a database or performing business computing. Through ASP, you can add interactive content for your web pages or use HTML pages to form the entire web application. These applications use HTML pages as your customer interface.
---- When we use ASP for database-related development, we often deal with images stored in the database. Generally, images are stored in blob (Binary Large Object) fields in the database. This article describes how to access the graph in the database in ASP.
---- Most browsers support GIF and JPEG format graphics files. Among them, ie supports GIF, JPEG, and BMP formats, while NC only supports GIF and JPEG. When an image is displayed, the browser sends a request to the server. When the Server transfers the image to the browser, it sets the MIME type in the HTTP header to image/GIF or image/JPEG, in this way, the browser will know what format should be used to display the image.
---- After understanding this truth, we will know how to process images in ASP. The following is a simple example showing the GIF format with the file name showgif. asp:
<% @ Language = VBScript %>
<%
'Clear header mark information
Response. expires = 0
Response. Buffer = true
Response. Clear
'Change contenttype to notify the browser to send a GIF
Response. contenttype = "image/GIF"
'The following are database operations
Set conn = server. Createobject
("ADODB. Connection ")
Conn. Open "Database", "sa", "password"
Set rs = cn. Execute ("select picture
From PIC where pic_id = '007 '")
'Return Image
Response. binarywrite RS ("logo ")
Response. End
%>
---- The function in this example is very simple. It just returns a graph. However, in practical applications, we often encounter situations where both graphics and text are returned. In this case, set the MIME type in the HTTP header to text/html. Otherwise, the text cannot be displayed. Therefore, we can use an HTML file and an ASP file. The HTML file can be written as follows:
<HTML>
<Head> <title> display text and images </title> <Body>
Here is the text, and below is the image <br>
</Body>
</Html>
---- The key in the example is to process the content returned by showgif. ASP as a graph.
---- The preceding processing method is not only applicable to graphics, but also effective for other binary data. For example, set the MIME type to application/MSWord to display the Word documents.
---- The example in this article runs through