会计考友 发表于 2012-7-31 22:26:35

ADO2.5比ADO2.1新增的两个实用对象

ADO2.5比ADO2.1新增的两个实用对象
 OFFICE 2000 安装的数据访问组件为 ADO 2.1
  OFFICE XP 安装的数据访问组件为 ADO 2.5
  ADO 2.5 比 ADO 2.1 新增的两个实用对象: Record 和 Stream
  一、Records 代表记录集、文件或文件系统目录中的一行。使用 Record 对象的一个例子是连接到一个URL的绝对或相对路径,并用 Record 对象管理相对路径的文件或目录。 Record 对象中的字段是文件或目录。下例演示了连接到一个URL并迭代相对于URL的每一个文件。
  Sub OpenRecord()
  Dim Record As New ADODB.Record
  Call Record.Open("","URL=http://localhost/",,adOpenIfExists Or adCreateCollection)
  Dim Recordset As New ADODB.Recordset
  Set Recordset = Record.GetChildren
  While Not Recordset.EOF
  Debug.Print Recordset(0)
  Recordset.MoveNext
  Wend
  End Sub
  注:要求本机安装了IIS才能测试本例
  二、Stream 与采用它们的大多数语言中的流类相似。流是定义来管理二进制流的类的名称。 Record 对象管理文件系统,流管理单个文件。下例演示了使用一个 Stream 对象在 Intranet 上读取文本文件。
  Sub OpenStream()
  Dim Record As New ADODB.Record
  Call Record.Open("Text.txt","URL=http://localhost/access/",,adModeRead)
  Dim Stream As New ADODB.Stream
  Call Stream.Open(Record, adModeRead, adOpenStreamFromRecord)
  Dim Text As String
  Stream.Charset = "ascii"
  Text = Stream.ReadText(adReadAll)
  Debug.Print
  End Sub
  注:要求本机安装了IIS才能测试本例,且在虚拟目录 access 下存在 Text.txt 文件
  即使OFFICE 2000没有这个组件,可下载 MDAC 2.5 或更高版本来升级数据访问组件
页: [1]
查看完整版本: ADO2.5比ADO2.1新增的两个实用对象