|
数据写入方式是
Sub BT录入() '读入到access的代码
Application.ScreenUpdating = False
Dim conn As New ADODB.Connection '连接
Dim rs As New ADODB.Recordset '记录
Dim connString As String
connString = "G:\Customer Service Division\Operations\00 Documents\03 Department\FA & repair\新维修组\维修数据库.MDB" '要打开的文件"
conn.Open "Provider = Microsoft.Jet.OLEDB.4.0;data source=" & connString & ";Jet OLEDB:Database Password=" & "admin"
str1 = "select * from BT原始" 'sql语句
rs.Open str1, conn, adOpenKeyset, adLockOptimistic '打开记录
'增加记录
For i = 5 To [A65536].End(xlUp).Row
rs.AddNew
rs.Fields(0) = Cells(i, 1)
rs.Fields(1) = Cells(i, 2)
rs.Fields(2) = Cells(i, 3)
rs.Fields(3) = Cells(i, 4)
rs.Fields(4) = Cells(i, 5)
rs.Fields(5) = Cells(i, 6)
rs.Fields(6) = Cells(i, 7)
rs.Fields(7) = Cells(i, 8)
rs.Fields(8) = Cells(i, 9)
rs.Fields(9) = Cells(i, 10)
rs.Fields(10) = Cells(i, 11)
rs.Fields(11) = Cells(i, 12)
rs.Fields(12) = Cells(i, 13)
rs.Fields(13) = Cells(i, 14)
rs.Fields(14) = Cells(i, 15)
rs.Fields(15) = Cells(i, 16)
rs.Fields(16) = Cells(i, 17)
rs.Fields(17) = Cells(i, 18)
rs.Fields(18) = Cells(i, 19)
rs.Fields(19) = Cells(i, 20)
rs.Fields(20) = Cells(i, 21)
rs.Fields(21) = Cells(i, 22)
rs.Fields(22) = Cells(i, 23)
rs.Fields(23) = Cells(i, 24)
rs.Fields(24) = Cells(i, 25)
rs.Fields(25) = Cells(i, 26)
rs.Fields(26) = Cells(i, 27)
Next i
rs.Update
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
Rows("5:65536").ClearContents
Range("a5").Select
MsgBox "BT录入完毕!!"
Application.ScreenUpdating = False
End Sub |
|