将ACCESS的ole对象导出为文件
来源:互联网 发布:宝贝故事软件下载 编辑:程序博客网 时间:2024/05/17 01:20
1.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 855
Left = 1440
TabIndex = 0
Top = 1080
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function ShellExecute()Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
'保存
Private Sub Command1_Click()Sub Command1_Click()
Dim bteContent() As Byte
Open "C:aa.DOC" For Binary Access Read As #1
bteContent = InputB(LOF(1), #1)
Close #1
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from tablename", cn, adOpenDynamic, adLockPessimistic
rs.AddNew
rs!Name = "张三"
rs!AGE = 22
rs!SEX = "男"
rs.Fields("PHOTO").AppendChunk bteContent
rs.Update
Erase bteContent
End Sub
'打开
Private Sub Command2_Click()Sub Command2_Click()
Dim bteContent() As Byte
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from tablename", cn, adOpenForwardOnly, adLockReadOnly
bteContent = rs.Fields("PHOTO").GetChunk(rs.Fields("PHOTO").ActualSize)
Open "F:.doc" For Binary Access Write As #1
Put #1, , bteContent
Close #1
ShellExecute Me.hWnd, "open", "F:.doc", vbNullString, vbNullString, SW_SHOW
End Sub
Private Sub Form_Load()Sub Form_Load()
On Error GoTo Errhandle
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:.mdb;Persist Security Info=False"
cn.Open
Exit Sub
Errhandle:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Form_QueryUnload()Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 855
Left = 1440
TabIndex = 0
Top = 1080
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function ShellExecute()Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
'保存
Private Sub Command1_Click()Sub Command1_Click()
Dim bteContent() As Byte
Open "C:aa.DOC" For Binary Access Read As #1
bteContent = InputB(LOF(1), #1)
Close #1
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from tablename", cn, adOpenDynamic, adLockPessimistic
rs.AddNew
rs!Name = "张三"
rs!AGE = 22
rs!SEX = "男"
rs.Fields("PHOTO").AppendChunk bteContent
rs.Update
Erase bteContent
End Sub
'打开
Private Sub Command2_Click()Sub Command2_Click()
Dim bteContent() As Byte
If rs.State = adStateOpen Then rs.Close
rs.Open "select * from tablename", cn, adOpenForwardOnly, adLockReadOnly
bteContent = rs.Fields("PHOTO").GetChunk(rs.Fields("PHOTO").ActualSize)
Open "F:.doc" For Binary Access Write As #1
Put #1, , bteContent
Close #1
ShellExecute Me.hWnd, "open", "F:.doc", vbNullString, vbNullString, SW_SHOW
End Sub
Private Sub Form_Load()Sub Form_Load()
On Error GoTo Errhandle
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:.mdb;Persist Security Info=False"
cn.Open
Exit Sub
Errhandle:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Form_QueryUnload()Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
1.vbp
Type=Exe
Form=Form1.frm
Reference=*G{00020430-0000-0000-C000-000000000046}#2.0#0#........WINDOWSsystem32stdole2.tlb#OLE Automation
Startup="Form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="cnpvp"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1
Form=Form1.frm
Reference=*G{00020430-0000-0000-C000-000000000046}#2.0#0#........WINDOWSsystem32stdole2.tlb#OLE Automation
Startup="Form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="cnpvp"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1
- 将ACCESS的ole对象导出为文件
- Perl Win32::OLE模块将Excel文件导出为文本文件
- [access查询]将access表导出为TXT文件及将TXT文件导入access表的几个SQL语句
- C# 操作Access的Ole对象
- ASP将access数据导出为excel电子表的方法
- 将默认实例下的指定数据库中的对象定义语句导出为文件
- 把notes里的以OLE形式存放的对象,导出成一个文件。
- Access存储图片(OLE对象)
- 将office2010 access的accdb文件保存为mdb格式
- C#读写Access数据库的OLE对象字段
- Access中创建含有OLE对象列的表
- 无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“Microsoft.VisualStudio.OLE.Interop.IServiceProvider”。
- 使用ole db连接带有工作组信息的Access文件.
- 将中DataSet的数据导出为EXCEL文件
- 将任意表数据导出为CSV文件的过程
- 将TensorFlow的网络导出为单个文件
- 如何将Access表结构信息导出为指定格式文件
- 将对象保存为文件
- 【经验】CruiseControl.Net的安装、配置和遇到的一些问题
- 更改远程桌面连接端口
- 获取CPU相关信息的实例
- VB 通过MSComm控件取得打印机的状态:正常、缺纸、卡纸等
- .sh打包
- 将ACCESS的ole对象导出为文件
- 图片连续循环滚动代码(向上)
- Posix线程同步2--条件变量(含代码实例)
- asp.net(C#) 大文件上传实例
- 海南民营胶调研
- 得失之间放手
- GBK和UTF8编码之间互相转换的两个函数
- 从SQL取出二进制文件并下载(多种文件类型)
- C#操作XML简明教程