如何用oracle数据库中的C#填充数据集

前端之家收集整理的这篇文章主要介绍了如何用oracle数据库中的C#填充数据集前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试填充oracle数据集== NULL;

我正在使用带有C#的.net框架2.0

这是一个system.data.oracleclient示例
http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter%28v=vs.71%29.aspx(此示例为1.1,但与2.0相同)

(来自链接的片段)

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

这是一个ODP(推荐)示例:
http://www.oracle.com/technology/sample_code/tech/windows/odpnet/DSPopulate/ViewProducts.cs.html

(来自链接的片段)

//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");
原文链接:https://www.f2er.com/oracle/205702.html

猜你在找的Oracle相关文章