2008-10-29 203 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