If str1 <> "" Then
str1 = str1 & " and 文件编号 like '%" & Text2 & "%' "
Else
str1 = "SELECT * FROM 资料信息 where 文件编号 like '%" & Text2 & "%' "
End If
End If
If Trim(Text3) <> "" Then
If str1 <> "" Then
str1 = str1 & " and 文件说明 like '%" & Text3 & "%' "
Else
str1 = "SELECT * FROM 资料信息 where 文件说明 like '%" & Text3 & "%' "
End If
End If
If str1 = "" Then str1 = " SELECT * FROM 资料信息 "
If rs0.State = adStateOpen Then rs0.Close
rs0.Open str1, strcn0, , , adCmdText '选择条件
If Not rs0.EOF Then
rs0.MoveFirst
List1.Clear
Do While Not rs0.EOF
If Not IsNull(rs0!存放路径) And rs0!存放路径 <> "" Then
List1.AddItem rs0!存放路径 & rs0!资料名
End If
rs0.MoveNext
Loop
Set DataGrid1.DataSource = rs0
Else
MsgBox "没有满足要求的文件资料!", vbOKOnly, "提示"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
If List1.Text <> "" Then
'读取数据库里的字段wj里的文件
Dim iStm As ADODB.Stream
'得到最新添加的纪录
If Rs1.State = adStateOpen Then Rs1.Close
Rs1.Open str1, strcn0, adOpenKeyset, adLockReadOnly
'保存到文件
Set iStm = New ADODB.Stream
With iStm
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write Rs1!wj '这里注意了,如果当前目录下存在此文件,会报一个文件写入失败的错误.
|