Private Sub ExportBankData(ByVal strFile As String, rsPayroll As ADODB.Recordset)
Dim cnDBF As ADODB.Connection
Dim strConString As String
Dim strPath As String
Dim strSql As String
On Error GoTo Errorhandle
If InStr(strFile, "\ ") > 0 Then
strPath = Left(strFile, InStrRev(strFile, "\ ", -1, vbTextCompare) - 1)
Else
strPath = "C: "
strFile = "C:\报盘.dbf "
End If
在 Form 上放置一个 CommandButton,加入 Microsoft DAO 3.51 Object Library,我们将使用 Biblio.mdb 的 authors Table,在 Command1_Click 中加入以下程序码:
Dim db As Database
Set db = Workspaces(0).OpenDatabase(App.Path & "\biblio.mdb")
'db.execute "SELECT Table.Fields INTO [dbms type;DATABASE=path].[unqualified filename] FROM [Table or Tables]"
在以上程序中,db.execute 指令行之指令依资料库或文件的种类说明如下:
DBase文件
SQL 语法:SELECT * INTO [dBase III;DATABASE=资料库路径].[dbase文件名称] FROM [authors]
db.Execute "SELECT * INTO [dBase III;DATABASE=C:\test].[authors.DBF] FROM [authors]"
注意事项:
1、authors.DBF 事先不可存在,否则会产生错误!
2、若您没有 Dbase,您可以使用 Access 来连结这个 Table,以便观察结果!