标题:读取access中长二进制文件
取消只看楼主
foreversun
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2011-1-11
结帖率:60%
已结贴  问题点数:10 回复次数:0 
读取access中长二进制文件
数据库file.mdb 表filetab  表中字段:fielid  filename filedes  
filedate为长二进制数据
其中一条为 fielid  7   filename  test.xls   filedes  test.xls   filedate长二进制数据

以下代码来自网上。
红字部分如何修改才能读出来并打开
源程序中通过   TreeView  选择后打开。怎样修改为指定打开如 fileid = filename  =
'读出来
Private Sub CommandButton1_Click()
Dim tast As String
'至少要引用Microsoft ActiveX Data Objects 2.5 Library
On Error Resume Next
Dim wordFile As String
If x = "" Then
MsgBox "参数错误,不能打开文档!"
Exit Sub
End If

z = LCase(Right(x, 3))
Set conn = CreateObject("ADODB.connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open ActiveDocument.Path & "\file.mdb"
Set rs = CreateObject("adodb.recordset")

sql = "select * from filetab where filenae =" & Chr(34) & CStr(x) & Chr(34)
rs.Open sql, conn, adOpenKeyset, adLockOptimistic
tast = ActiveDocument.Path & "\TempTest.tmp"
If Dir(tast) <> "" Then
Kill tast
End If
Set StmWord = New ADODB.Stream
With StmWord
 .Mode = adModeReadWrite
 .Type = adTypeBinary
 .Open
 .Write rs!内容
 .SaveToFile tast
 .Close
End With
 rs.Close
 Set rs = Nothing
 Set conn = Nothing
If z = "doc" Then
 EXE = "Winword.exe"
 ElseIf z = "xls" Then
   EXE = "excel.exe"
 Else
   EXE = "mspaint.exe"
 End If
Call Shell(EXE & Chr(9) & Chr(34) & tast & Chr(34), 1)

If Err <> 0 Then
MsgBox "指定的打开参数有误,不能正确执行打开操作。"
Exit Sub
End If
End Sub
搜索更多相关主题的帖子: Microsoft access 二进制 数据库 源程序 
2013-12-13 13:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-425141-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.090798 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved