141 lines
2.8 KiB
C#
141 lines
2.8 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
using System.Data.OleDb;
|
|||
|
//using Oracle.DataAccess.Client;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Web;
|
|||
|
using Tracen.Utils;
|
|||
|
|
|||
|
namespace Tracen.Data.DataAccess
|
|||
|
{
|
|||
|
internal class Execution : IDisposable
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
private String _Sql = null;
|
|||
|
private SqlConnection _Conn = null;
|
|||
|
private SqlCommand _sqlCmd = null;
|
|||
|
|
|||
|
public Execution()
|
|||
|
{
|
|||
|
_Conn = new Connection().getSqlCon();
|
|||
|
_sqlCmd = new SqlCommand();
|
|||
|
_sqlCmd.Connection = _Conn;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public Execution(String Sql)
|
|||
|
{
|
|||
|
_Sql = Sql;
|
|||
|
_Conn = new Connection().getSqlCon();
|
|||
|
_sqlCmd = new SqlCommand(_Sql, _Conn);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
public Execution(String Sql, SqlConnection Conn)
|
|||
|
{
|
|||
|
_Sql = Sql;
|
|||
|
_Conn = Conn;
|
|||
|
_sqlCmd = new SqlCommand(_Sql, _Conn);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public SqlCommand SqlCmd
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _sqlCmd;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public SqlDataReader GetDataReader()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
return _sqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_Conn.Close();
|
|||
|
throw ex;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
public DataSet getData()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
DataSet ds = new DataSet();
|
|||
|
using (SqlDataAdapter oda = new SqlDataAdapter(_sqlCmd))
|
|||
|
{
|
|||
|
oda.Fill(ds);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
_Conn.Close();
|
|||
|
return ds;
|
|||
|
}
|
|||
|
catch ( Exception er )
|
|||
|
{
|
|||
|
throw er;
|
|||
|
}finally
|
|||
|
{
|
|||
|
_Conn.Close();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
public int Execute()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
int affectRows = _sqlCmd.ExecuteNonQuery();
|
|||
|
|
|||
|
_Conn.Close();
|
|||
|
return affectRows;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_Conn.Close();
|
|||
|
throw ex;
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
_Conn.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
public int getNextSeqValue(String SequenceName)
|
|||
|
{
|
|||
|
String strSql = "SELECT " + SequenceName + ".nextval from dual";
|
|||
|
_sqlCmd.CommandText = strSql;
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
DataSet ds = getData();
|
|||
|
|
|||
|
return int.Parse(ds.Tables[0].Rows[0][0].ToString());
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void Dispose()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|