Created
May 31, 2016 10:56
-
-
Save MrToxy/2e087ea7f4015148d3288676c5e2cea2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Data.OleDb; | |
using System.Runtime.InteropServices; | |
using Microsoft.Win32.SafeHandles; | |
using Oracle.ManagedDataAccess.Client; | |
namespace CDPSI.UPDATE.SQL | |
{ | |
public class CdpsiUpdateSql : IDisposable | |
{ | |
private OracleTransaction _myTransaction; | |
bool disposed = false; | |
SafeHandle handle = new SafeFileHandle(IntPtr.Zero, true); | |
public OracleConnection OraConnection { get; set; } | |
public CdpsiUpdateSql(OracleConnection connectionString) | |
{ | |
this.OraConnection = OpenDb(connectionString); | |
} | |
public CdpsiUpdateSql() | |
{ | |
} | |
private OracleConnection OpenDb(OracleConnection conection) | |
{ | |
conection.Open(); | |
return conection; | |
} | |
public string LookUp(string sColuna, string sTabela, string sWhere) | |
{ | |
var comando = @"SELECT " + sColuna + " FROM " + sTabela + " WHERE " + sWhere; | |
var Return = ""; | |
var select = new OracleCommand(comando, OraConnection); | |
var reader = select.ExecuteReader(); | |
reader.Read(); | |
Return = reader.GetString(0); | |
return Return; | |
} | |
public void BeginTrans() | |
{ | |
_myTransaction = this.OraConnection.BeginTransaction(); | |
} | |
public void Commit() | |
{ | |
_myTransaction.Commit(); | |
_myTransaction = null; | |
} | |
public void Rollback() | |
{ | |
_myTransaction.Rollback(); | |
_myTransaction = null; | |
} | |
public void Dispose() | |
{ | |
Dispose(true); | |
GC.SuppressFinalize(this); | |
} | |
protected virtual void Dispose(bool disposing) | |
{ | |
if (disposed) | |
return; | |
if (disposing) | |
{ | |
handle.Dispose(); | |
// Free any other managed objects here. | |
// | |
} | |
// Free any unmanaged objects here. | |
// | |
disposed = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment