<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

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

      [摘要]上次提到基本的配置注意問題,現在開始實際開發oracle中的問題一 oracle 數據庫的連接但你裝了oracle的客戶端,在配置時就已經指定了數據庫服務器,所以連接時主要由三個元素就可以連接上數據...
      上次提到基本的配置注意問題,現在開始實際開發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();

      adapter.Fill(dataset);

      this.DataGrid1.DataSource=dataset;

      DataGrid1.DataBind();

      con.Close();



      3.怎么使用存儲過程

      OracleConnection conn = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");

      Conn.Open;

      OracleCommand cmd = conn.CreateCommand();

      cmd.CommandText = "sp_pkg.getdata";

      cmd.CommandType = CommandType.StoredProcedure;

      cmd.Parameters.Add(new OracleParameter("a1", OracleType.Cursor)).Direction = ParameterDirection.Output;

      cmd.Parameters.Add(new OracleParameter("a2", OracleType.Cursor)).Direction = ParameterDirection.Output;

      DataSet ds = new DataSet();

      OracleDataAdapter adapter = new OracleDataAdapter(cmd);

      adapter.Fill(ds);





      日韩精品一区二区三区高清