adp中仿accdb的附件管理功能
adp中仿accdb的附件管理功能 ,自力更生,自己做个用。
看这个添加的代码,就明白是用 adodb.stream 来实现了
Private Sub AppendFile_Click() '添加功能
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
Me.CommonDialog9.Filter = "All Files|*.*"
Me.CommonDialog9.FileName = ""
Me.CommonDialog9.ShowOpen
If Me.CommonDialog9.FileName <> "" Then
Set iStm = New ADODB.Stream
With iStm
.Type = adTypeBinary '二进制模式
.Open
.LoadFromFile Me.CommonDialog9.FileName
End With
' CurrentProject.Connection.Execute "insert dbo.OrderSaleFile(OrderSaleID,FileName,OrderSaleFile) values(" & Form_OrderSaleEdit.OrderSaleID.Value & ",'" & Me.CommonDialog9.FileName & "','" & iStm.Read & "')"
'打开保存文件的表
Set iRe = New ADODB.Recordset
With iRe
.Open "dbo.OrderSaleFile", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
.AddNew '新增一条记录
.Fields("OrderSaleID") = Form_OrderSaleEdit.OrderSaleID.Value
.Fields("FileName") = GetFileName(Me.CommonDialog9.FileName)
.Fields("OrderSaleFile") = iStm.Read
.Update
End With
Me.FileList.Requery
End If
'完成后关闭对象
iRe.Close
iStm.Close
Set iRe = Nothing
Set iStm = Nothing
End Sub
补充:VB , VBA