- ©«¤l
- 12
- ¥DÃD
- 4
- ºëµØ
- 0
- ¿n¤À
- 12
- ÂI¦W
- 0
- §@·~¨t²Î
- 7
- ³nÅ骩¥»
- 7
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2012-9-13
- ³Ì«áµn¿ý
- 2024-11-9
|
VBA ³s½u MySQL
¦bºô¸ô¤W§äªº«Ü¦h³s½u¸ê®Æ³£¬On¥ý¦w¸ËMYSQLªºDRIVER
¦]¬°¤p§Ìn°µªºTOOL¬Onµ¹«Ü¦h¤H¨Ï¥Î¡A¨S¿ìªk½T«O¨C¦ì¢ý¢û¢í¢ú³£·|³]©w
¦³¨S¦³¿ìªk¦b¤£³]©w¤Þ¥Î¶µ¥Øªº«e´£¤§¤U¡A³]©w»Pmysql³s½u©O¡H
§Y¬O¨Ï¥Î³s½u¦r¦ê¡B³]©wª«¥óªº¤è¦¡µ¥...
³oÃä©ß¿j¤Þ¥É¤@¤U¡A§Ú´£¨ÑMSSQLªº³]©w¡A§Ú¥Î³oºØ¤è¦¡ªº¸Ü¡A¢ã¢á¢Ó¢à´N¤£¥Î³]©w¤Þ¥Î¿ï¶µ¨º¨Ç¡Aª½±µ°õ¦æ´N·|³s½u¥hDB¼´¸ê®Æ¤F
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = Sheets("Config").Range("B" & i)
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array("OLEDB;Provider=SQLOLEDB.1;Password=xxx;User ID=xxx;Trusted_Connection=False;Persist Security Info=True;Data Source=projdb;Use Procedure for Prepare=1;Auto Tran" _
, _
"slate=True;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=Mantis_Mirror"), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM xxx " & Query_Mysql & Query_Date_Start & Query_Date_End)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = Sheets("Config").Range("B" & i)
.Refresh BackgroundQuery:=False
End With |
|