请帮我看看一段程序

langtao1982 2004-09-06 10:04:17
我看了一些贴子讲如何将word存放到数据库的问题,但有一点我不是很懂,而且我运行了一下出了"找不到任何可安装ISAM",不知道错误在哪里?我在img.mdb中建立的TableName表中只有一个字段"word"
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim StmWord As ADODB.Stream

Private Declare Sub InitCommonControls Lib "comctl32.dll" ()

Private Sub Form_Initialize()
InitCommonControls
End Sub

'调用WORD函数
Sub OpenWord(FileName As String)
Dim WordTemps As New Word.Application
WordTemps.Documents.Add FileName, False
WordTemps.Visible = True
End Sub

Private Sub Form_Load()
Dim iConcStr As String
iConcStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _
";Data Source=F:\img.mdb"
Dim iConc As ADODB.Connection
Set iConc = New ADODB.Connection
iConc.Open iConcStr

End Sub

Private Sub cmdSave_Click()
Set rs = New ADODB.Recordset
rs.Open "select * from TableName", _
cn, adOpenKeyset, adLockOptimistic
Set StmWord = New ADODB.Stream
With StmWord
.Type = adTypeBinary
.Open
.LoadFromFile "F:\test.doc"
End With
rs.AddNew
rs.Fields(1).Value = StmWord.Read
rs.Update
StmWord.Close
rs.Close
End Sub

'读取数据库中的Word文档
Private Sub cmdRead_Click()
Dim Sql As String
Sql = "select * from TableName where id=3"
Set rs = New ADODB.Recordset
rs.Open Sql, cn, adOpenKeyset, adLockOptimistic
Set StmWord = New ADODB.Stream
With StmWord
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write rs!Word
.SaveToFile App.Path & "\TempTest.doc"
.Close
End With
Call OpenWord(App.Path & "\TempTest.doc")
rs.Close
End Sub


...全文
51 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tzmchf 2004-09-06
你的方法应该没问题,Access对应的字段类型要设置要准确!
请参考下面的信息:
http://www.china-askpro.com/msg1/qa26.shtml
回复
lovebeethoven 2004-09-06
帮顶
回复
langtao1982 2004-09-06
高手去哪儿了?
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2004-09-06 10:04
社区公告
暂无公告