/// <summary>
/// Execute mutil-SQL(insert,delete,update)command,keep an affair.
/// </summary>
/// <param>SQL Command collection which will be Executed</param>
/// <returns>return the list number of the rows which are affected</returns>
public List<int> ExecuteSqlDic(Dictionary<string, SqlParameter[]> dic)
{
debug("Now Execute DataBaseAccess's Method:ExecuteSqlDic(Dictionary<string, SqlParameter[]>),Return Type:List<int> ");
return ExecuteSqlDic(dic, false);
}
#endregion
#region
/// <summary>
/// Execute SQL Command,Return single Result.
/// </summary>
/// <param>SQL Command collection which will be Executed</param>
/// <returns>return single Result</returns>
public object ExecScalar(SqlCommand sqlcmd)
{
debug("Now Execute DataBaseAccess's Method:ExecScalar(SqlCommand),Return Type:object ");
sqlcmd.Connection = this.conn;
try
{
debug("Execute SQL Command:" + sqlcmd.CommandText);
this.conn.Open();
object r = sqlcmd.ExecuteScalar();
//if (Object.Equals(r, null))
//{
// throw new Exception("object is null!");
//}
//else
//{
// return r;
//}
return r;
}
catch (SqlException ex)
{
debug("Exception Information:" + ex.ToString());
throw ex;
}
finally
{
sqlcmd.Dispose();
this.conn.Close();
}
}
/// <summary>
/// Execute SQL Command,Return single Result.
/// </summary>
/// <param>SQL Command collection which will be Executed</param>
/// <returns>return single Result</returns>
public object ExecScalar(string strSql)
{
debug("Now Execute DataBaseAccess's Method:ExecScalar(string),Return Type:object ");
return ExecScalar(new SqlCommand(strSql,this.conn));
}