iT邦幫忙

2

Visual Studio 如何設定 Oracle連線及驅動程式安裝

一 目的
利用Microsoft Visual Studio 連線Oracle資料庫開發圖文並茂報表或是Web相關應用程式。

二 環境說明
用戶端 Windows 7 64位元 + Visual Studio 2017 community Version 15.9.19
伺服器端 Oracle 11G R2 64位元

三 開發使用說明
3.1 開啟程式集
點選Visual Studio程式進入主畫面,畫面顏色會因為設定而有所不同。
https://ithelp.ithome.com.tw/upload/images/20200121/20011825h822y2YPoX.png

3.2 測試目前連線資料庫驅動程式
點選工具-->連接到資料庫
https://ithelp.ithome.com.tw/upload/images/20200121/20011825FtZE431qKW.png

此時會出現警告視窗,表示.NET Framework已經被取代,請改用連結的驅動程式,你可以點選連結下載檔案或是下載這一個連結
https://ithelp.ithome.com.tw/upload/images/20200121/20011825Ro71OCC8QE.png

https://ithelp.ithome.com.tw/upload/images/20200121/20011825rmide03eJw.png

3.3 檔案下載完成後直接安裝
點選剛剛下載檔案名稱是 ODTforVS2017_183000.exe,安裝完成後出現底下畫面
https://ithelp.ithome.com.tw/upload/images/20200121/20011825ptS0QuJSQ2.png

3.4 連結註冊元件
請到你的目錄 C:\Program Files (x86)\Oracle Developer Tools for VS2017\odt 點選Oracle.VsDevTools.15.0.vsix後完成一般檔案安裝及元件註冊動作。
https://ithelp.ithome.com.tw/upload/images/20200121/20011825HCeMprtDqm.png

https://ithelp.ithome.com.tw/upload/images/20200121/20011825gGIiDRK7fT.png

3.5 設定tnsnames.ora檔案
確認你的oracle連線檔案 tnsnames.ora 是設定正確,請把檔案放置C:\Program Files (x86)\Oracle Developer Tools for VS2017\network\admin中。
tnsnames.ora設定方式請參閱
一般TNSNAMES.ORA 範例,ABC 打入你的Oracle SID, HOST打入你的Oracle DB IP address

ABC=
    (DESCRIPTION=
        (ADDRESS=
            (PROTOCOL=TCP)
            (HOST=172.29.1.1)
            (PORT=1521)
        )
        (CONNECT_DATA=
            SID=ABC)
        )
     )   

3.6 連線測試
工具-->連線到資料庫,請依照底下方式選擇到Oracle的正確連線元件
https://ithelp.ithome.com.tw/upload/images/20200121/200118255WiUybEIyf.png

請輸入登錄Oracle帳號及密碼,這裡的示範是使用TNS方式連線,設定完成後你可以按下測試連線,若沒問題會出現連線成功畫面。
https://ithelp.ithome.com.tw/upload/images/20200121/20011825gd6i9RsVZG.png

https://ithelp.ithome.com.tw/upload/images/20200121/20011825ciXw79xG3u.png

3.7 Oracle 連線程式範例
安裝於C:\Program Files (x86)\Oracle Developer Tools for VS2017\samples\odp.net.managed\4 有很多範例可以參考此目錄下的範例程式。


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言