.net+oracle+crystalReports開發web應用程式學習筆記(二)

來源:互聯網
上載者:User
上次提到基本的配置注意問題,現在開始實際開發oracle中的問題
一 oracle 資料庫的串連
但你裝了oracle的用戶端,在配置時就已經指定了資料庫伺服器,所以串連時主要由三個元素就可以串連上資料庫,資料庫的名稱(即SID),使用者名稱,密碼
SqlConnection con=new SqlConnection("Provider=MSDAORA.1;User ID=UserID;Data Source=xf;Password=password")
而sql Server不需要安裝用戶端,所以必須指定伺服器,和資料庫名
SqlConnection con=new SqlConnection("workstation id=XIAOFENG;packet size=4096;user id=sa;integrated security=SSPI;data source=xiaofeng;persist security info=False;initial catalog=xf");
二 在oracle中運行包(Package)中的函數和預存程序。
舉個例子,要運行下面一個sql語句:"select order_no,inventory_part_api.get_description(contract,part_no),part_no from SHOP_ORD where inventory_part_api.get_description(contract,part_no) like '%喜之郎25%果凍%'";
1.在.net設計中(如設計sqlDataAdapter)不能夠直接使用包中的函數和預存程序,如果要使用,可以在設計時把包中要使用的函數和預存程序copy過來再設計時聲明一遍,就可以使用
2.在.net運行時直接添加代碼,系統會直接去尋中包中的內容
string strCommand;
strCommand="select order_no,inventory_part_api.get_description(contract,part_no),part_no from SHOP_ORD where inventory_part_api.get_description(contract,part_no) like '%喜之郎25%果凍%'";
OleDbConnection con=new OleDbConnection("Provider=MSDAORA.1;Password=password;User ID=UserID;Data Source=xf");
con.Open();
OleDbDataAdapter adapter=new OleDbDataAdapter(strCommand,con);
DataSet dataset = new DataSet();

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.