设为首页 加入收藏

TOP

[C#]分享一个以前的项目使用的DataBaseAccess类(四)
2014-11-24 14:34:34 来源: 作者: 【 】 浏览:9
Tags:分享 一个 以前 项目 使用 DataBaseAccess
xecute DataBaseAccess's Method:ExecScalarEx(SqlCommand),Return Type:int ");
sqlcmd.Connection = this.conn;
try
{
debug("Execute SQL Command:" + sqlcmd.CommandText);
this.conn.Open();
SqlDataReader myDr = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);


if (myDr.Read())
{
return 1;
}
else
{
return 0;
}
}
catch (SqlException ex)
{
debug("Exception Information:" + ex.ToString());
throw ex;
}
finally
{
sqlcmd.Dispose();
this.conn.Close();
}
}


///


/// 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(string strSql)
{
debug("Now Execute DataBaseAccess's Method:ExecScalarEx(strSql),Return Type:int ");
return ExecScalarEx(new SqlCommand(strSql, this.conn));
}


///


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

/// SQL Command which will be Executed
/// SQL Command Collection
/// Execute SQL command,if result set has note return 1,if result set is null return 0
public int ExecScalarEx(string strSql, SqlParameter[] sqlParameters)
{
debug("Now Execute DataBaseAccess's Method:ExecScalarEx(string,SqlParameter[]),Return Type:int ");
return ExecScalarEx(SQLHelper.CreateCommand(strSql, sqlParameters, this.conn));
}


#endregion


#region ExecuteSqlDs


///


/// Execute SQL Command,return DataSet.
///

/// SQL Command which will be Executed
/// table name
/// return DataSet.
public DataSet ExecuteSqlDs(SqlCommand sqlcmd, string strTableName)
{
debug("Now Execute DataBaseAccess's Method:ExecuteSqlDs(SqlCommand,string),Return Type:DataSet ");
sqlcmd.Connection = this.conn;
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
DataSet dsReturn = new DataSet();
try
{
debug("Execute SQL Command:" + sqlcmd.CommandText);
this.conn.Open();
sqlda.Fill(dsReturn, strTableName);
return dsReturn;
}
catch (SqlException ex)
{
debug("Exception information:" + ex.ToString());
throw ex;
}
finally
{
sqlcmd.Dispose();
sqlda.Dispose();
this.conn.Close();
}
}

///
/// Execute SQL Command,return DataSet.
///

/// SQL Command which will be Executed
/// table name
/// return dataset.
public DataSet ExecuteSqlDs(string strSql, string strTableName)
{
debug("Now Execute DataBaseAccess's Method:Exec
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 4/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C# 在winform画面上点击某个区域.. 下一篇C#中生成验证码的类

评论

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