色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

vba怎么將excel數據插入mysql數庫庫

劉柏宏2年前43瀏覽0評論

vba怎么將excel數據插入mysql數庫庫?

1、定義連接db的過程:Dim oConn As ADODB.ConnectionPrivate Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={mysql ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ "DATABASE=yourdatabase;" & _ "USER=yourdbusername;" & _ "PASSWORD=yourdbpassword;" & _ "Option=3"End Sub2、執行db插入的具體寫法:Dim rs As ADODB.RecordsetPrivate Sub InsertData() Set rs = New ADODB.Recordset ConnectDB With wsBooks For rowCursor = 2 To 11 strSQL = "INSERT INTO tutorial (author, title, price) " & _ "VALUES ('" & esc(.Cells(rowCursor, 1)) & "', " & _ "'" & esc(.Cells(rowCursor, 2)) & "', " & _ esc(.Cells(rowCursor, 3)) & ")" rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic Next End WithEnd Sub