如何修改VB找开access中的文件为指定的fileid
Set rs = New ADODB.Recordsetrs.Open "Select * from fileTab where fileid=" & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0), cn, adOpenKeyset, adLockOptimistic
当fileid = 7 filename="test.xls时 如何修改
rs.Open "Select * from fileTab where fileid=7 "
报错。
实例在 https://bbs.bccn.net/thread-353402-1-1.html中
谢谢
Dim f As String
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Dim strfileName As String
On Error GoTo errlab
Set rs = New ADODB.Recordset
rs.Open "Select * from fileTab where fileid=" & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0), cn, adOpenKeyset, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields("Filedata").Value
strfileName = rs("filename")
mstream.SaveToFile App.Path & "\" & strfileName, adSaveCreateOverWrite
rs.Close
Call ShellExecute(0, "open", strfileName, 0, 0, 1)
Exit Sub
errlab:
MsgBox "打开文件出错!", vbExclamation, "错误"