vba¨Ï¥ÎADO±NEXCEL¸ê®Æ¾É¤J¨ìSQL Server
- ©«¤l
- 8
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 52
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office 2016
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-3-17
- ³Ì«áµn¿ý
- 2017-6-6
|
vba¨Ï¥ÎADO±NEXCEL¸ê®Æ¾É¤J¨ìSQL Server
Sub test()
Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;Data Source=xxx;" & _
"Initial Catalog=Mydata;User ID=sa;Password=54123"
'Import by using OPENROWSET and SELECT query.
strSQL = "SELECT * INTO Newtable FROM " & _
"OPENROWSET('Microsoft.ACE.OLEDB.12.0', " & _
"'Excel 12.0;Database=C:\Users\My\Desktop\222.xlsx', " & _
"[Sheet1$])"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff
cn.Close
Set cn = Nothing
End Sub
¨Ï¥Îsql server³sµ²¦øªA¾¹Excellink
Select * From Openquery(Excellink,'Select * from [sheet1$]')
¥i¥H¥¿½T¾É¤JExcel¼Æ¾Ú¨ìSql Server
µM¦Ó¥ÎVBA ADO¾É¤J ´N·|³ø¿ù,½Ð°Ý¬O§_¬OÅv°ÝÃD? |
|
|
|
|
|
|