最近偵錯工具遇到了些問題,還是在64位機器上有關32/64位odbc驅動的問題,程式使用udl檔案串連資料庫,但是機器上沒有安裝64位驅動,如何使udl檔案尋找32位驅動,以下文章給了靈感:
1、ODBC在Server 2003 64機器出現的問題:在Server 2003 64機器上開啟控制台->找到管理工具->找到ODBC開啟->在驅動程式選項中只發現了SqlServer驅動別的都麼有,點擊系統DSN選項->點擊add後發現裡面沒有別的只有SqlServer的,這就是我在這連天遇到的第一個問題。這個問題到底是什麼原因導致呢。這個問題也花費了我不少時間,下面我來解釋一下:
這個問題是由於我忽略了一個大前提,那就是作業系統是Server 2003 64位的,只要注意到這個大前提,那麼這個問題就解決了一半。64位系統跟32位系統還是有區別的,odbc和下面的要講的udl檔案都是跟系統有關的。你在控制台上找到的odbc是32位的所以裡面沒有其他的資料庫驅動,其實在64位系統中有他自己的odbc,它存放在\WINDOWS\SysWOW64/檔案夾下。那麼你在這個檔案加下找到odbcad32.exe,雙擊開啟就可以看到所有資料庫驅動了。
2、32位的udl檔案在Server 2003 64機器出現的問題:我在32位機子上使用的udl檔案測試連接時沒有問題,發在64位機子上進行測試連結是卻出現串連錯誤,提示不能串連資料來源、找不到資料來源,這個問題也話費了我好長時間。其實也是問題也是出在系統的問題上。64位系統處理32位系統上的udl檔案時,有自己的策略。詳細下面的英文說明:
“UDL Test” on a 64 bit machine
Let’s say you’ve started playing with UDL files on your "32 bit" machine and this tiny little UDL files helped you to identify connectivity issues or you’ve easily obtained the OLE DB connection strings for your applications. So far so good. But one day, you followed the same procedure on a 64 bit machine and couldn’t see the OLE DB Providers though you’re sure that it’s been installed. There must be something wrong then ?
The reason behind for this is simple. When you double clicked on a UDL file on a 64 bit machine, it’ll enumerate only the 64 bit OLE DB Providers and most probably you’ve installed a 32 bit OLE DB Provider.
So then, there should be a way of making UDL Test using the 32 bit OLE DB Providers on a 64 bit machine.
Actually when you’ve created a UDL file on a 64 bit machine and double clicked on it,
"C:\Program Files\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\test.udl
command will be called through C:\windows\system32\rundll32.exe
Both binaries (oledb32.dll and rundll32.exe) used here are 64 bit and 64 bit oledb32.dll does not deal with 32 bit OLE DB Providers.
Since we already have 32 bit versions of those oledb32.dll and rundll32.exe in other folders on our 64 bit machines, we need to use them. Therefore, instead of double clicking on the UDL file, we’ll need to execute the command below from a command line or Start/Run :
C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\test.udl
Et voila :) There you have your 32 bit OLE DB Providers.
上面這篇英文文章是來自http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/udl-test-on-a-64-bit-machine.aspx的,由於我自身英語翻譯水平的原因沒有翻譯,解決方案是:C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\test.udl 這裡的C:\test.udl是你的udl檔案的路徑。解決問題的思想跟上面的一樣。
===========================================================================
1、查看64位Win系統內的32位元據庫驅動的方法 查看32位ODBC驅動:啟動 C:/Windows/SysWOW64/odbcad32.exe 查看64位ODBC驅動,啟動 C:/WINDOWS/system32/odbcad32.exe 或者去控制台 查看32位OLEDB驅動:
啟動一個32位cmd環境 start C:/WINDOWS/SysWOW64/cmd.exe
在這個32位環境內執行 start xxx.udl 就會啟動32位子系統的Rundll32來管理UDL資料庫連接。 2、查看64位OLEDB驅動:建立一個xxx.udl,雙擊開啟。
3、其它
SysWOW64是個什麼檔案夾?
WoW64 (Windows-on-Windows 64-bit)是一個Windows作業系統的子系統
Rundll32.exe C:/PROGRA~1/COMMON~1/system/OLEDB~1/oledb32.dll,OpenDSLFile %1
C:/Windows/SysWOW64/Rundll32.exe C:/PROGRA~2/COMMON~1/system/OLEDB~1/oledb32.dll,OpenDSLFile %1
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC
HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/ODBC
HKEY_CLASSES_ROOT/Wow6432Node/.UDL
HKEY_CLASSES_ROOT/Wow6432Node/MSDASC/shell/open/command
HKEY_CLASSES_ROOT/.UDL
HKEY_CLASSES_ROOT/MSDASC/shell/open/command