|
/// <summary>
/// Execute stored procedure
/// </summary>
/// <param name="storedProcName">stored procedure name</param>
/// <param name="parameters">stored procedure parameters</param>
/// <param name="tableName">the name of the table in the DataSet result</param>
/// <returns>DataSet</returns>
public static DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
DataSet dataSet = new DataSet();
if (connection.State != ConnectionState.Open)
connection.Open();
SqlDataAdapter sqlDA = new SqlDataAdapter();
sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters);
sqlDA.Fill(dataSet, tableName);
if (connection.State == ConnectionState.Open)
connection.Close();
return dataSet;
}
} |
|