Exemplo n.º 1
0
        private void button15_Click(object sender, EventArgs e)
        {
            String _connstring = "Data Source=localhost/NEWDB;User Id=EDZEHOO;Password=PASS123;";

            try
            {
                OracleConnection _connObj = new OracleConnection(_connstring);
                _connObj.Open();
                OracleCommand _cmdObj = _connObj.CreateCommand();
                _cmdObj.CommandText = " proc_InsertProduct";
                _cmdObj.CommandType = CommandType.StoredProcedure;
                //Instantiate your UDT class here and specify the data for your new record
                PRODUCTTYPE _product = new PRODUCTTYPE();
                _product.NAME  = "SPARETYRE";
                _product.PRICE = 400;
                _product.ID    = "Y1";
                //Declare a UDT-based parameter and pass the instantiated class into this
                //parameter
                OracleParameter param = new OracleParameter();
                param.OracleDbType = OracleDbType.Object;
                param.Direction    = ParameterDirection.Input;
                param.UdtTypeName  = "EDZEHOO.PRODUCTTYPE";
                param.Value        = _product;
                _cmdObj.Parameters.Add(param);
                int result = _cmdObj.ExecuteNonQuery();
                if (result > 0)
                {
                    MessageBox.Show("Product successfully added");
                }
                _connObj.Close();
                _connObj.Dispose();
                _connObj = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    public virtual IOracleCustomType CreateObject()
    {
        PRODUCTTYPE obj = new PRODUCTTYPE();

        return(obj);
    }