|
以下为excel 批量导入到 access ,请问如何在VBA excel平台上,将excel 表批量导入到 sqlserver2000,使用insert
Private Sub ADO_UPDATE_ACCESS_Click()
Dim endline%, line%, addr$, sql$
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & _
"\通讯录.mdb;Jet OLEDB:Database Password=123"
endline = [a65536].End(xlUp).Row
For line = 4 To endline
conn.Execute ("delete from 档案1 where 姓名='" & Cells(line, "a") & "'") '先整条删除再整条插入比逐字段更新速度应快
Next
addr = Range(Cells(3, "a"), Cells(endline, [iv3].End(xlToLeft).Column)).Address(0, 0) '得到数据区的地址
sql = "INSERT INTO [档案1] SELECT * FROM [Excel 8.0;Database=" & ThisWorkbook.FullName & ";HDR=YES].[sheet1$" & addr & "];"
conn.Execute sql
MsgBox "更新完毕"
conn.Close
Set conn = Nothing
End Sub
跪求: |
|