当前位置: 首页 > 图文教程 > 网络编程 > ASP > 从Access数据库恢复BMP图像并显示在WEB页面(microsoft)

ASP
在ASP程序中实现数据库事务控制
怎样开始一个ASP网站的设计
ASP中使用ServerVariables集合详解
关于解决商务平台ASP程序的源代码泄漏设想与思考
ASP通用模板类
javascript利用xmlhttp获得服务器时钟的方法
asp+oracle分页程序类(XDOWNPAGE2.0)
ASP中实现小偷程序的原理和简单
asp中vbscript访问xml文件
ASP防SQL注入攻击程序
用ASP读INI配置文件的函数
asp实现关键词获取(各搜索引擎,gb2312及utf-8)
xmlhttp组件获取远程文件并筛选出目标数据
XMLHTTP Get HTML页面时的中文乱码之完全客户端Script解决方案
WEB打印设置解决方案一(通过修改注册表改变IE打印设置)
WEB打印设置解决方案二(利用ScriptX.cab控件改变IE打印设置)
WEB打印设置解决方案三(FileSystem组件实现WEB打印)
WEB打印设置解决方案四(在ASP中实现网络打印功能)
ASP实用技巧 强制刷新网页
Access通用-自动替换数据库中的字符串

ASP 中的 从Access数据库恢复BMP图像并显示在WEB页面(microsoft)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 84 ::
收藏到网摘: n/a

  HOWTO: Retrieving Bitmap from Access and Displaying In Web Page

--------------------------------------------------------------------------------
The information in this article applies to:

Active Server Pages
Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
ActiveX Data Objects (ADO), versions 1.0, 1.5, 2.0, 2.1 SP2, 2.5
Microsoft Internet Information Server versions 4.0, 5.0
Microsoft Data Access Components version 2.5

--------------------------------------------------------------------------------


SUMMARY
This article shows by example how to extract the bitmap photos in the Microsoft Access 97 Northwind.mdb
database, and view them from a Web browser using Active Server Pages (ASP). In order to accomplish this
task, an ActiveX DLL must be created that strips the Access and OLE headers from the field. This article
shows how to create this ActiveX DLL, and how to implement it.



MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this
code "as is" without warranty of any kind, either express or implied, including but not limited to the
implied warranties of merchantability and/or fitness for a particular purpose.

This article demonstrates how to use Visual Basic to retrieve a bitmap stored in an OLE Object field.
Because the definition of OLE object storage is not documented, the following code searches the object's
OLE header for characters consistent with the start of the graphic. This method may not work in all
circumstances.

Be aware that Internet Explorer 3.0 is unable to display true color bitmaps. For this reason, the bitmaps
stored in the Access database should be no higher than 256 colors.

Step-by-Step Example to Extract the Photos
Create a new project in Visual Basic and make the project an ActiveX DLL.


Add a reference to ActiveX Data Objects (ADO) by clicking the Project menu and selecting References.
Select "Microsoft OLE DB ActiveX Data Objects 1.0 Library" and click OK.


Add a new module to the project by selecting the Project menu and clicking Add Module. Select Module and
click Open.


Place the following code in the (general) (declarations) section of MODULE1.BAS:

      ' Enter the following Declare statement as one single line:
      Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
       (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

      Type PT
        Width As Integer
        Height As Integer
      End Type

      Type OBJECTHEADER
        Signature As Integer
        HeaderSize As Integer
        ObjectType As Long
        NameLen As Integer
        ClassLen As Integer
        NameOffset As Integer
        ClassOFfset As Integer
        ObjectSize As PT
        OleInfo As String * 256
      End Type



Place the following code in the (general) (declarations) section of CLASS1.CLS:

        Function DisplayBitmap(ByVal OleField As Variant)
        Dim Arr() As Byte
        Dim ObjHeader As OBJECTH