日期:2014-05-20 浏览次数:20782 次
namespace ESWS
{
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using ESWS;
internal class MySqlHelper : IDisposable
{
private MySqlCommand mySqlCommand;
private MySqlConnection mySqlConnection;
private MySqlDataAdapter mySqlDataAdapter;
private MySqlTransaction myTransaction;
protected virtual void AddParameters(MySqlCommand command, MySqlParameter[] parameters)
{
foreach (MySqlParameter parameter in parameters)
{
command.Parameters.AddWithValue(parameter.ParameterName, parameter.Value);
}
}
internal void BegionTransaction()
{
if (this.DBConnection.State != ConnectionState.Open)
{
this.DBConnection.Open();
}
this.myTransaction = this.DBConnection.BeginTransaction();
}
internal void Commit()
{
this.DBTransaction.Commit();
}
protected MySqlCommand CreateCommand(string commandText)
{
return this.CreateCommand(commandText, CommandType.Text);
}
protected MySqlCommand CreateCommand(string commandText, CommandType commandType)
{
return this.CreateCommand(commandText, commandType, null);
}
protected MySqlCommand CreateCommand(string commandText, MySqlParameter[] parameters)
{
return this.CreateCommand(commandText, CommandType.Text, parameters);
}
protected MySqlCommand CreateCommand(string commandText, CommandType commandType, MySqlParameter[] parameters)
{
return this.CreateCommand(this.DBConnection, commandType, commandText, 30, parameters);
}
protected MySqlCommand CreateCommand(MySqlConnection connection, CommandType commandType, string commandText, int commandTimeout, MySqlParameter[] parameters)
{
MySqlCommand mySqlCommand;
try
{
using (this.mySqlCommand = new MySqlCommand())
{
if (connection.State != ConnectionState.Open)
{
connection.Open();