Calling an image in SQL from ASP:
How to deal with images in ASP When programming with ASP, images are often used. For simply processing an image from a database, we have talked a lot about it, and it is not difficult. You can see the following code: Here, suppose you have a database name: PUBS, there is a table called: PUB_INFO in the database, and there is a BLOB column of LOGO in the table. We found photos of people with PUB_ID=0736. FILE: ****************************************** < %@ LANGUAGE="VBSCRIPT" %> < % ' Clear out the existing HTTP header information = 0 = TRUE ' Change the HTTP header to reflect that an image is being passed. = "image/gif" Set cn = ("") ' The following open line assumes you have set up a System DataSource ' by the name of myDSN. "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs" Set rs = ("SELECT logo FROM pub_info WHERE pub_id='0736'") rs("logo") %> ****************************************************** Execute this ASP file to see the image you exist in the database. But if you are processing text and images at the same time, it will be a bit difficult: (For example: for an enterprise's personnel management, the backend database can be SYBASE or SQL SERVER, etc. (I use SQL SERVER here) When you need to use BROWSE/SERVER method within the enterprise, that is, when you use a browser to view employee personal information, you must process text information and use skills about images. The problem is that when you display text information, you must use CONTENT="TEXT/HTML" in the HTML HEAD, and the image display must be CONTENT="IMAGE/GIF" or CONTENT="IMAGE/JPEG". Therefore, you cannot use only one ASP file to combine text information and The solution is to process the image with a separate ASP file, and then call the ASP file in the ASP file that processes the text information. Here I will introduce my solution to you, I hope you will discuss it together: Environment: WINNT4.0 SQL SERVER IIS3.0 Database name: RSDA Table name: RSDA_TABLE Purpose: Find out the information of the person with ID=00001 from RSDA_TABLE, including name, age and photos. Step 1: Create a query form: ****************************************************** < html> < head> < /head> < body> < form method="POST" action=""> < p>Please enter the number: < input type="text" name="T1" size="20"> < input type="submit" value="submit" name="B1"> < /form> < /body> ****************************************** The second step: Create ************************************************* < html> < head> < meta http-equiv="content-type" content="text/html;charset=gb2312"> < title>Query results</title> < /head> < body bgColor=Azure> < % session("RSDA_ID")=("T1") 'Here I used a SESSION variable to call temp_id=session("RSDA_ID") < font size=4 color=OrangeRed> Query result: < /font> < %set conntemp=("") "dsn=RSDA;uid=sa;pwd=SA" set rstemp=("select * from RSDA_TABLE where rsda='"&temp_id&"'") % > < % 'put headings on the table of field names nobody="Sorry! There is no information you are looking for in our database! "%> 'Judge whether there is this person < %if then % > < font size="5" color=OrangeRed> < %(nobody)% >< /font> < %else% > < div align="center"> < center> < table border="1" width="73%" height="399"> < tr> < td width="21%" height="49" align="center">Name</td> < td width="30%" height="49" align="center"> < font size=4 color=OrangeRed>< /font>< /td> < /td> < tr> < p align="center"> Age</ /td> < td width="30%" height="47" align="center"> < font size=4 color=OrangeRed>< %=rstemp(0)% >< /font>< /td> < /tr> < tr> < td width="49%" height="146" rowspan="3" colspan="2"> < img src="">< /td> 'It is the ASP file we will create that specializes in processing images < /tr> < /table> < /center>< /div> set rstemp=nothing set conntemp=nothing % > < /BODY> < /HTML> ********************************** The third step: Create an ASP file that processes the image. () ********************************************* < % = 0 = TRUE ' Open database Set conntemp = ("") "dsn=RSDA;uid=sa;pwd=SA" 'change http header = "image/jpeg" ' or "IMAGE/GIF" ' Get picture TEMP_ID=session("RSDA_ID") Set Rs = ("SELECT photo from RSDA_table where ID='"&TEMP_ID&"'") Rs("photo") % > *************************************** The main trick here is to use a SESSION variable to implement two querying of the same condition. As I mentioned above, you can achieve that a page has both text and images with just a few changes!
Some things that are often used by asp,
Previous page1234567891011121314151617181920Next pageRead the full text