ow;
}
finally
{
this.conn.Close();
}
}
}
#endregion
#endregion
#region other
///
///Close DataBase Connection.
///
public void CloseDB()
{
if (this.conn != null)
{
if (this.conn.State != ConnectionState.Closed)
this.conn.Close();
}
}
///
/// Dispose Resource
///
public void Dispose()
{
if (this.conn != null)
{
if (this.conn.State != ConnectionState.Closed)
this.conn.Close();
this.conn.Dispose();
}
}
#endregion
}
#endregion
#region DataBase Operate assistant class SQLHelper
///
/// SQLHelper.
///
public abstract class SQLHelper
{
///
/// DataBase ConnectionString
///
public static string StrConn = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
//------------------------------------------------------------------------------------------------------------
///
/// Create SqlParameter.
///
/// The name of the parameter to map.
/// One of the System.Data.SqlDbType values.
/// The length of the parameter.
/// Return new SqlParameter.
public static SqlParameter CreateSqlParameter(string parameterName, SqlDbType DbType, object value)
{
SqlParameter sqlpara = new SqlParameter(parameterName, DbType);
sqlpara.Value = value;
return sqlpara;
}
///
/// Create SqlParameter.
///
/// The name of the parameter to map.
/// One of the System.Data.SqlDbType values.
/// Return new SqlParameter.
public static SqlParameter CreateSqlParameter(string parameterName, SqlDbType DbType, int size, object value)
{
SqlParameter sqlpara = new SqlParameter(parameterName, DbType, size);
sqlpara.Value = value;
return sqlpara;
}
//------------------------------------------------------------------------------------------------------------
///
/// Param amortize Hashtable
///
private static Hashtable htParamCache = Hashtable.Synchronized(new Hashtable());
///
/// Save Parameters in Cache
///
///
///
public static void CacheParameters(string strCacheKey, params SqlParameter[] sqlParameters)
{
SQLHelper.htParamCache[strCacheKey] = sqlParameters;
}
///
/// Get Parameters from Cache
///
///
///
public static SqlParameter[] GetCachedParameters(string strCacheKey)
{
SqlParameter[] sqlParameters = (SqlParameter[])SQLHelper.htParamCache[strCacheKey];
if (sqlParameters == null)
{
return null;
}
SqlParameter[] clonedParms = new SqlParameter[sqlParameters.Length];
for (int i = 0, j = sqlParameters.Length; i < j; i++)
{
clonedParms[i] = (