各位大侠:  
       我在做一个信息查询系统的二次开发,其中要求:  
   1、在vb中如何使用代码,将磁盘A中的gz_data.dbf表中的所有数据导入到后台Access数据库gz_data.mdb表中?两个表中所有的字段、数据类型、长度等都相同。  
   感谢!!!

解决方案 »

  1.   

    select * into newtable from Table IN "a:\" "dBASE IV;"
      

  2.   

    我自己已经解决,谢谢朋友!!
    Dim a2 As ADODB.Connection
    Dim b2 As ADODB.Recordset
    Dim a1 As ADODB.Connection
    Dim b1 As ADODB.Recordset
    Dim i As Integer
    Dim str1 As String
    Dim str2 As String
    Set a1 = New ADODB.Connection
    Set b1 = New ADODB.Recordset
    Set a2 = New ADODB.Connection
    Set b2 = New ADODB.Recordset
    str1 = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=tablename ' ——.dbf表在系统的用户DNS中添加dBase驱动连接
    str2 = "provider=Microsoft.jet.oledb.4.0;data source=e:\temp\test.mdb" 'access的连接
    a1.Open str1
    a2.Open str2
    b1.CursorLocation = adUseClient
    b2.CursorLocation = adUseClient
    b1.Open "select * from hello", a1, adOpenStatic, adLockOptimistic
    b2.Open "select * from access", a2, adOpenStatic, adLockOptimistic
    MsgBox b1.RecordCount
    MsgBox b2.RecordCount
    For i = 1 To b1.RecordCount
        b2.AddNew
        b2.Fields("uid") = rst1.Fields("uid").Value
        b2.Fields("name") = rst1.Fields("na").Value
        b2.UpdateBatch
        b1.MoveNext
    Next i
    MsgBox("数据导入完成!")