Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Bagaimana cara mengisi dataset dengan C# dari database Oracle

di sini adalah contoh system.data.Oracleclienthttp://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter%28v=vs.71%29.aspx (contoh ini adalah 1.1 tetapi akan berfungsi sama dengan 2.0)

(cuplikan dari tautan)

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);

berikut adalah contoh ODP (disarankan):http://www.Oracle.com/technology/sample_code/tech/windows/odpnet/DSPopulate/ViewProducts.cs.html

(cuplikan dari tautan)

//Instantiate OracleDataAdapter to create DataSet
productsAdapter = new OracleDataAdapter();

//Fetch Product Details
productsAdapter.SelectCommand = new OracleCommand("SELECT " +
                                                  "Product_ID , " +
                                                  "Product_Name , " +
                                                  "Product_Desc , " +
                                                  "Category, " +
                                                  "Price " +
                                                  "FROM Products",conn);

//Instantiate DataSet object
productsDataSet = new DataSet("productsDataSet");

//Fill the DataSet with data from 'Products' database table
productsAdapter.Fill(productsDataSet, "Products");

//setting 'productsDataSet' as  the datasouce and 'Products' table
//as the table to which the 'productsDataGrid' is Bound.
productsDataGrid.SetDataBinding(productsDataSet,"Products"); 



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Oracle PL/SQL - Bagaimana cara membuat variabel array sederhana?

  2. Bagaimana Anda mendapatkan tanggal maksimum yang mungkin di Oracle?

  3. Jalankan 2 kueri secara bersamaan di Oracle SQL Developer?

  4. Layanan Database di AWS dan Oracle Cloud Platform

  5. indeks penurunan oracle jika ada