public static byte[] ExecuteDataReader(string sql, string connStr, params OracleParameter[] parameters)
        {
            using (OracleConnection conn = new OracleConnection(connStr))
            {
                conn.Open();
                using (OracleCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    cmd.Parameters.AddRange(parameters);
                    OracleDataReader reader = cmd.ExecuteReader();

                    MemoryStream ms = new MemoryStream();

                    if (reader.Read())
                    {
                        OracleBlob blob   = (OracleBlob)reader.GetOracleBlob(0);
                        Byte[]     buffer = new Byte[blob.Length];
                        blob.Read(buffer, 0, Convert.ToInt32(blob.Length));
                        ms.Write(buffer, 0, Convert.ToInt32(blob.Length));
                        blob.Close();
                    }
                    reader.Close();
                    ms.Position = 0;
                    byte[] result = new byte[ms.Length];
                    ms.Read(result, 0, result.Length);
                    return(result);
                }
            }
        }
Ejemplo n.º 2
0
 private void FreeLob()
 {
     if (lob == null)
     {
         return;
     }
     lob.Close();
     lob.Dispose();
     lob = null;
 }