小弟我想做一个软件,需要把.dbf数据文件和.xls文件分别导入到SQL数据库中.如果sql的表中存在相同的记录则覆盖(sql表中的字段比dbf和xls中的字段多).请问该如何实现!

解决方案 »

  1.   

    Excle导入SQL:
    '引用ADO(Microsoft ActiveX Data Objects 2.X Library)
    Private Sub Command1_Click()
        On Error GoTo err
        Dim cn As New ADODB.Connection
        cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=123;Initial Catalog=dataBase001;Data Source=mySERVICE"
        cn.CursorLocation = adUseClient
        cn.Open    
        cn.Execute "select * into table4 from OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=Yes;database=c:\Test.xls;','select * from [Sheet1$]')"
        cn.Close
        Set cn=Nothing
        Exit Sub
    err:
        MsgBox err.Description
    End Sub
      

  2.   

    连接.dbf数据文件
    conn.ConnectionString = "provider=msdasql;DRIVER=Microsoft Visual FoxPro Driver;UID=;Deleted=yes;Null=no;Collate=Machine;BackgroundFetch=no;Exclusive=No;SourceType=DBF;SourceDB=C:\FOX\DATA;"