设为首页 加入收藏

TOP

[C#]分享一个以前的项目使用的DataBaseAccess类(三)
2014-11-24 14:34:34 来源: 作者: 【 】 浏览:10
Tags:分享 一个 以前 项目 使用 DataBaseAccess
ar();
return iReturnValueList;
}
}
trans.Commit();
}
catch (SqlException ex)
{
debug("Exception Information:" + ex.ToString());
trans.Rollback();
throw ex;
}
finally
{
this.conn.Close();
}


return iReturnValueList;
}


///


/// Execute mutil-SQL(insert,delete,update)command,keep an affair.
///

/// SQL Command collection which will be Executed
/// return the list number of the rows which are affected
public List ExecuteSqlDic(Dictionary dic)
{
debug("Now Execute DataBaseAccess's Method:ExecuteSqlDic(Dictionary),Return Type:List ");
return ExecuteSqlDic(dic, false);
}


#endregion


#region


///


/// Execute SQL Command,Return single Result.
///

/// SQL Command collection which will be Executed
/// return single Result
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();
}
}

///
/// Execute SQL Command,Return single Result.
///

/// SQL Command collection which will be Executed
/// return single Result
public object ExecScalar(string strSql)
{
debug("Now Execute DataBaseAccess's Method:ExecScalar(string),Return Type:object ");
return ExecScalar(new SqlCommand(strSql,this.conn));
}


///


/// Execute SQL Command,Return single Result.
///

/// SQL Command collection which will be Executed
/// SQL Parameters Collection
/// return single Result
public object ExecScalar(string strSql, SqlParameter[] sqlParameters)
{
debug("Now Execute DataBaseAccess's Method:ExecScalar(string,SqlParameter[]),Return Type:object ");
return ExecScalar(SQLHelper.CreateCommand(strSql, sqlParameters, this.conn));
}


#endregion


#region ExecScalarEx


///


/// Execute SQL command,if result set has note return 1,if result set is null return 0
///

/// SQL Command which will be Executed
/// Execute SQL command,if result set has note return 1,if result set is null return 0
public int ExecScalarEx(SqlCommand sqlcmd)
{
debug("Now E
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 3/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C# 在winform画面上点击某个区域.. 下一篇C#中生成验证码的类

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: