|
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OracleClient;
namespace WindowsApplication2
{
class Signature
{
/// <summary>
/// Inserts a BLOB into an Oracle DataBase
/// </summary>
/// <param name="connectionString">The ConnectionString to the database</param>
/// <param name="signatureBytes">Signature bytes to be saved</param>
public static void UploadImage(string connectionString, byte[] signatureBytes)
{
try
{
OracleConnection conn = new OracleConnection(connectionString);
conn.Open() ;
OracleCommand cmd = new OracleCommand("insert into tabel(Signature) values(:Signature)", conn);
//OracleCommand cmd = new OracleCommand("update courrierlog set Signature=:Signature where id = 312", conn);
cmd.Parameters.Add("Signature", OracleType.Blob) ;
cmd.Parameters["Signature"].Value = signatureBytes;
cmd.ExecuteNonQuery();
conn.Close();
}
catch(Exception ex)
{
throw ex;
}
}
/// <summary>
/// Downloads a byte[] from a BLOB
/// </summary>
/// <param name="connectionString"></param>
/// <returns></returns>
public static byte[] DownloadImage(string connectionString)
{
try
{
OracleConnection conn = new OracleConnection(connectionString);
conn.Open();
OracleCommand cmd = new OracleCommand("select signature from tabel order by id desc", conn);
//OracleCommand cmd = new OracleCommand("select signature from courrierlog where id = 312", conn);
byte[] barrImg = cmd.ExecuteScalar() as byte [];
conn.Close();
return barrImg;
}
catch(Exception ex)
{
throw ex;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.