*停權中*
|
以下是部分前人用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資料
謝謝
|