Wednesday, November 19, 2014

filling DataSet by calling oracle stored procedure

Use the below code as a reference.


public void GetDatainDataset()
{

 using (OracleConnection conn = new OracleConnection(strConnStr))            {                conn.Open();

                OracleCommand cmdABC = new OracleCommand();

                cmdABC.Connection = conn;

                cmdABC.CommandType = CommandType.StoredProcedure;

                cmdABC.CommandText = Stored Procedure Name;

                cmdABC.Parameters.Add("P_RC", OracleDbType.RefCursor).Direction                 = ParameterDirection.Output;

                DataSet ds = new DataSet();

                OracleDataAdapter adapter = new OracleDataAdapter(cmdPlants);

                adapter.Fill(ds);

                ddlABC.DataSource = ds.Tables[0];

                ddlABC.DataTextField = "A";

                ddlABC.DataValueField = "B";

                ddlABC.DataBind();

                conn.Close();

                conn.Dispose();}