Ejemplo n.º 1
0
        /// <summary>
        /// 输出blob
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        public byte[] OutputBlob(string strSql)
        {
            //string block="SELECT image  from test_image WHERE id = 100";//INTO :b
            // Set command to create Anonymous PL/SQL Block

            command.CommandText = strSql + "";
            command.CommandType = System.Data.CommandType.Text;
            Oracle.DataAccess.Client.OracleDataReader reader;
            // The anonymous PL/SQL block retrieves the images as an output parameter
            try
            {
                //cmd.ExecuteNonQuery();
                reader = command.ExecuteReader();
            }
            catch (OracleException ex)
            {
                this.Err       = "执行产生错误!" + ex.Message;
                this.ErrCode   = strSql;
                this.DBErrCode = ex.Number;
                this.WriteErr();
                return(null);
            }
            catch (Exception ex)
            {
                this.Err            = ex.Message;
                this.ErrorException = ex.InnerException + "+ " + ex.Source;
                this.WriteErr();
                return(null);
            }

            reader.Read();
            // Create a byte array
            byte[] byteData = new byte[0];

            // fetch the value of Oracle parameter into the byte array
            //byteData = (byte[])(cmd.Parameters[0].Value);
            try
            {
                byteData = (byte[])(reader[0]);
            }
            catch { }
            reader.Close();
            return(byteData);
        }
Ejemplo n.º 2
0
        private void updateDataGrid()
        {
            Oracle.DataAccess.Client.OracleCommand cmd = con.CreateCommand();
            cmd.CommandText = "SELECT KUPACID,NAZIV,PIB FROM KUPACPRAVNOLICE";
            cmd.CommandType = CommandType.Text;
            Oracle.DataAccess.Client.OracleDataReader dr = cmd.ExecuteReader();
            // DataTable dt = new DataTable();
            //  dt.Load(dr);
            // myDataGrid.ItemsSource = dt.DefaultView;


            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            dt.Columns.Add("KUPACID");
            dt.Columns.Add("NAZIV");
            dt.Columns.Add("PIB");
            ds.Tables.Add(dt);
            OracleParameter valueToReturn = null;

            while (dr.Read())
            {
                DataRow red = dt.NewRow();
                red["KUPACID"] = dr.GetValue(0);
                red["NAZIV"]   = dr.GetString(1);
                Pib mBroj = (Pib)dr.GetValue(2);
                //  Pib mm = new Pib();
                // mm= (Pib)dr.GetValue(2);



                // red["PIB"] = Convert.ToInt64(mm.Pibb);
                red["PIB"] = Convert.ToInt64(mBroj.Pibb);
            }


            dr.Close();
        }