![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 七嘴八舌異言堂
(https://www.pcdvd.com.tw/forumdisplay.php?f=12)
- - [求助]EXCEL的VBA資料庫連接?
(https://www.pcdvd.com.tw/showthread.php?t=958094)
|
---|
[求助]EXCEL的VBA資料庫連接?
3個附加檔案
以下是部分前人用EXCEL內VBA連接資料庫的語法
因為是本機連接PROXY後 再透過PROXY驗證去抓取SQL資料 Option Explicit Public Const strINTDBConnection = "DSN=INTDB;UID=SMTAPP;PWD=SMTAPP;" Public Const strINTDBCFConnection = "DSN=INTDB;UID=EF3EDA1;PWD=EF3EDA1;" Public Const strTWProxyIP = "http://10.165.111.16" Public Const gstrFileDriveForCim = "J:\" Public Const gstrPZAT = "''" Public Const gstrBright = "'BRIGHT'" Public Const cntQueryByPID = 1 Public Const cntQueryByGID = 2 Public Const cntQueryByDefectCode = 3 Public Const cntQueryByDateTime = 4 Public Const cntQueryByCID = 5 Public strProxyIP As String Public strSetTableConnection As String Public gstrSMTFab As String Public gstrSMTConnection As String Public gstrSMTConnection As String Public strLossTableName As String Public strDefectTableName As String Public gstrShop As String Public gstrShopTo As String 'Public gstrFab As String Public frmCTmp As New frmDhis Public frmSMTTmp As New frmSMT 'Public frmCTmp As New frmDhis Public Sub SetParameter(strShop As String) gstrShopTo = Sheets("SMT").txtSMTShopTo Select Case strShop Case "V3" gstrShop = "V3" gstrSMTFab = "LDSˇ" strLossTableName = "INT_RAWHIS_" & gstrShop strDefectTableName = "INT_LONDFT_" & gstrShop gstrSMTConnection = strINTDBConnection gstrSMTConnection = strINTRMConnection Case default gstrSMTConnection = "" gstrSMTConnection = "" MsgBox gstrShop & " => Fab Number does not Define. please call the programer." Exit Sub End Select If gstrShop = "JP" Then strProxyIP = strJPProxyIP51 strSetTableConnection = strJPINConnection ElseIf gstrShop = "KO" Then strProxyIP = strKOProxyIP51 strSetTableConnection = strKOINConnection ElseIf gstrShop = "En" Then strProxyIP = strEnProxyIP51 strSetTableConnection = strEnINConnection ElseIf gstrShop = "HK" Then strProxyIP = strHKProxyIP51 strSetTableConnection = strHKINConnection ElseIf gstrShop = "CN" Then strProxyIP = strCNProxyIP51 strSetTableConnection = strCNINConnection ElseIf gstrShop = "TW" Or gstrShop = "TW" Then strProxyIP = strTWProxyIP strSetTableConnection = strINTDBConnection Else strProxyIP = strAKProxyIP strSetTableConnection = strINTDBCFConnection End If End Sub 請問如果不用VBA的話 該如何設定使用EXCEL內建的 "匯入外部資料" 來抓取所需的SQL資料 謝謝 |
關鍵字:ODBC ??
|
每個選項都選過了
還是沒辦法透過精靈連接 |
所有的時間均為GMT +8。 現在的時間是03:18 AM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2025。