You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.4 KiB
109 lines
2.4 KiB
6 months ago
|
using System;
|
||
|
using System.Data;
|
||
|
using System.Data.OleDb;
|
||
|
|
||
|
namespace Kingo.RuleCheck.CheckHelper
|
||
|
{
|
||
|
public class MDBHelper
|
||
|
{
|
||
|
private OleDbConnection Conn;
|
||
|
|
||
|
public MDBHelper()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public MDBHelper(string connStr)
|
||
|
{
|
||
|
Conn = new OleDbConnection($"provider=Microsoft.JET.OLEDB.4.0;Data Source={connStr}");
|
||
|
}
|
||
|
|
||
|
public void connOpen()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
Conn.Open();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DataTable ExecuteDataTable(string commandText)
|
||
|
{
|
||
|
DataTable table = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
using (OleDbDataAdapter adp = new OleDbDataAdapter(commandText, Conn))
|
||
|
{
|
||
|
adp.Fill(table);
|
||
|
}
|
||
|
return table;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public OleDbDataReader ExecuteDataReader(string commandText)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
using (OleDbCommand comm = new OleDbCommand(commandText, Conn))
|
||
|
{
|
||
|
return comm.ExecuteReader();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public object ExecuteScalar(string commandText)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
using (OleDbCommand comm = new OleDbCommand(commandText, Conn))
|
||
|
{
|
||
|
return comm.ExecuteScalar();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public object ExecuteNonQuery(string commandText)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
using (OleDbCommand comm = new OleDbCommand(commandText, Conn))
|
||
|
{
|
||
|
return comm.ExecuteNonQuery();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void DisConn()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (Conn != null)
|
||
|
{
|
||
|
Conn.Dispose();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|