Private Sub download_Click()
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, "错误"
End Sub