PCDVD數位科技討論區
PCDVD數位科技討論區   註冊 常見問題 標記討論區為已讀

回到   PCDVD數位科技討論區 > 其他群組 > 七嘴八舌異言堂
帳戶
密碼
 

回應
 
主題工具
公不
*停權中*
 

加入日期: Dec 2010
文章: 341
[求助]EXCEL的VBA資料庫連接?

以下是部分前人用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資料

謝謝
     
      
上傳的圖像
文件類型: jpg Snap14.jpg (81.9 KB, 143次瀏覽)
文件類型: jpg Snap15.jpg (95.1 KB, 141次瀏覽)
文件類型: jpg Snap16.jpg (117.7 KB, 141次瀏覽)

此文章於 2012-02-10 08:49 PM 被 公不 編輯.
舊 2012-02-10, 08:48 PM #1
回應時引用此文章
公不離線中  
PAN_PAN
Junior Member
 
PAN_PAN的大頭照
 

加入日期: Jan 2003
您的住址: Shattrath City
文章: 948
關鍵字:ODBC ??
 
舊 2012-02-10, 09:14 PM #2
回應時引用此文章
PAN_PAN離線中  
公不
*停權中*
 

加入日期: Dec 2010
文章: 341
每個選項都選過了

還是沒辦法透過精靈連接
舊 2012-02-12, 08:12 PM #3
回應時引用此文章
公不離線中  


回應


POPIN
主題工具

發表文章規則
不可以發起新主題
不可以回應主題
不可以上傳附加檔案
不可以編輯您的文章

vB 代碼打開
[IMG]代碼打開
HTML代碼關閉



所有的時間均為GMT +8。 現在的時間是11:45 AM.


vBulletin Version 3.0.1
powered_by_vbulletin 2025。