[C#]分享一个以前的项目使用的DataBaseAccess类(九)

2014-11-24 14:34:34 · 作者: · 浏览: 34
SqlParameter)((ICloneable)sqlParameters[i]).Clone();
}


return clonedParms;
}


//----------------------------------------------------------------------------------------------------------------


///


/// Create new SqlComand
///

///
public static SqlCommand CreateCommand(string strSql)
{
SqlCommand sqlcmd = new SqlCommand(strSql);
return sqlcmd;
}


///


/// Create new SqlComand,Set DataBase Connection
///

///
///
///


public static SqlCommand CreateCommand(string strSql, SqlConnection sqlconn)
{
SqlCommand sqlcmd = new SqlCommand(strSql, sqlconn);
return sqlcmd;
}



///


/// Create new SqlComand which has Parameters
///

///
///
public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters)
{
SqlCommand sqlcmd = new SqlCommand(strSql);
foreach (SqlParameter param in sqlParameters)
{
sqlcmd.Parameters.Add(param);
}
return sqlcmd;
}


///


/// Create new SqlComand which has Parameters,Set DataBase Connection
///

///
///
///
public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters, SqlConnection sqlconn)
{
SqlCommand sqlcmd = new SqlCommand(strSql, sqlconn);
foreach (SqlParameter param in sqlParameters)
{
sqlcmd.Parameters.Add(param);
}
return sqlcmd;
}


///


/// Create new SqlComand which has Parameters,Set Stored Procedure Flag
///

///
///
///
///
public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters, bool bIsStoredProcedure)
{
SqlCommand sqlcmd = new SqlCommand(strSql);


if (bIsStoredProcedure)
sqlcmd.CommandType = CommandType.StoredProcedure;
else
sqlcmd.CommandType = CommandType.Text;


foreach (SqlParameter param in sqlParameters)
{
sqlcmd.Parameters.Add(param);
}
return sqlcmd;
}


///


/// Create new SqlComand which has Parameters,Set Stored Procedure Flag and DataBase Connection
///

///
///
///
///
public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters, bool bIsStoredProcedure, SqlConnection sqlconn)
{
SqlCommand sqlcmd = new SqlCommand(strSql, sqlconn);


if (bIsStoredProcedure)
sqlcmd.CommandType = CommandType.StoredProcedure;
else
sqlcmd.CommandType = CommandType.Text;


foreach (SqlParameter param in sqlParameters)
{
sqlcmd.Parameters.Add(param);
}
return sqlcmd;
}


///


/// Create new SqlDataAdapter which has Parameters and set DataBase Connection
///

///
///
public static SqlDataAdapter CreateDataAdapter(string strSql,