日期:2014-05-18  浏览次数:20902 次

求高手帮忙给下面的方法写上详细注释,最好是每一行写一个,30分辛苦费双手奉上
using System.Data.OleDb;
using System.Collections;

using System.Data.SqlClient;
using System.Data.Sql;

/// <summary>
/// Summary description for OleDbHelper
/// </summary>
public class OleDbHelper
{


  public static string strConnection
  {
  get
  {
  if(!Common.IsEnglish)
  {
  return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(Common.ChinesedbPath);

  }
  else
  return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(Common.EnglishdbPath);
  }
  }



  private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());

  #region ExecuteNonQuery

  public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
  {

  OleDbCommand cmd = new OleDbCommand();

  using (OleDbConnection conn = new OleDbConnection(connectionString))
  {
  PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
  int val;
  try
  {
  val = cmd.ExecuteNonQuery();
  }
  finally
  {
  cmd.Parameters.Clear();
  conn.Close();
  }
  return val;
  }
  }


  public static int ExecuteNonQuery(CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
  {
  OleDbCommand cmd = new OleDbCommand();

  using (OleDbConnection conn = new OleDbConnection(strConnection))
  {
  PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
  int val;
  try
  {
  val = cmd.ExecuteNonQuery();
  }
  finally
  {
  cmd.Parameters.Clear();
  conn.Close();
  }
  return val;
  }
  }


  public static int ExecuteNonQuery(string cmdText, params OleDbParameter[] commandParameters)
  {

  OleDbCommand cmd = new OleDbCommand();

  using (OleDbConnection conn = new OleDbConnection(strConnection))
  {
  PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, cmdText, commandParameters);
  int val;
  try
  {
  val = cmd.ExecuteNonQuery();
  }
  finally
  {
  cmd.Parameters.Clear();
  conn.Close();
  }
  return val;
  }
  }

  public static int ExecuteNonQuery(OleDbConnection connection, CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
  {

  OleDbCommand cmd = new OleDbCommand();

  PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
  int val;
  try
  {