BINARYWRITE是RESPONSE用来传达室送二进制数据的一种方法。一般都是由一个产生二进制数据的组件或由数据库的BLOB类型字段形成二进制数据。然后由BINARYWRITE发出。但是在发出之前,为了让浏览器识别,需要将CONTENTTYPE设置成对应的二进制说明格式。比如传送JPEG图象,须指明为IMAGE/JPEG类型。
<%@ LANGUAGE="VBSCRIPT" %> <%
' Clear out the existing HTTP header information Response.Expires = 0
Response.Buffer = TRUE Response.Clear
' Change the HTTP header to reflect that an image is being passed.
Response.ContentType = "image/gif"
Set cn = Server.CreateObject("ADODB.Connection")
' The following open line assumes you have set up a System DataSource
' by the name of myDSN. cn.Open "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs"
Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
Response.BinaryWrite rs("logo") Response.End %>
可在MSDN中以BINARYWRITE进行查询。