2008-10-29 202 views

回答

2

你必須以編程方式做到這一點。

  1. 打開源表
  2. 創建使用ADO擴展一個新ACCESSDB(如上所示)
  3. 通過讀取源模式中創建ACCESSDB表(CREATE TABLE X ...)
  4. 迭代以爲源表在Access表中插入記錄

注:代碼從http://www.freevbcode.com/ShowCode.asp?ID=5797張貼在這裏的情況下存在的鏈接停止在未來

'select References from the Project Menu, choose the COM tab, 
    'and add a reference to Microsoft ADO Ext. 2.7 for DDL and Security 

    Public Function CreateAccessDatabase(ByVal DatabaseFullPath As String) As Boolean 
     Dim bAns As Boolean 
     Dim cat As New ADOX.Catalog() 
     Try 


     'Make sure the folder 
     'provided in the path exists. If file name w/o path 
     'is specified, the database will be created in your 
     'application folder. 

      Dim sCreateString As String 
      sCreateString = _ 
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ 
       DatabaseFullPath 
      cat.Create(sCreateString) 

      bAns = True 

     Catch Excep As System.Runtime.InteropServices.COMException 
      bAns = False 
      'do whatever else you need to do here, log, 
      'msgbox etc. 
     Finally 
      cat = Nothing 
     End Try 
     Return bAns 
    End Function 


    DEMO 
    ==== 


    '  If CreateAccessDatabase("F:\test.mdb") = True Then 
    '   MsgBox("Database Created") 
    '  Else 
    '   MsgBox("Database Creation Failed") 
    '  End If